A heterogeneous catalyst (HPW/mpg‐C 3 N 4 ) for the alkylation of o ‐xylene and styrene reaction was acquired by the immobilization of phosphotungstic acid (HPW) on mesoporous graphitic carbon nitride (mpg‐C 3 N 4 ) through electrostatic interaction. The results of Fourier transform infrared spectroscopy (FT‐IR), X‐ray powder diffraction (XRD), X‐ray photoelectron spectroscopy (XPS) and thermogravimetric analysis (TGA) proved that HPW was successfully immobilized on the protonated mpg‐C 3 N 4 by electrostatic interaction. The textural properties and morphology of HPW/mpg‐C 3 N 4 were characterized by N 2 adsorption–desorption, scanning electron microscopy (SEM). Among them, 40% HPW/mpg‐C 3 N 4 displays the best catalytic performance in the alkylation reaction with 91.8% yield and 96.5% selectivity to 1, 2‐diphenylethylane. Moreover, protonated mpg‐C 3 N 4 not only displays as a support to facilitate great dispersion of HPW but also promotes the alkylation product diffusion effectively. Besides, the HPW/mpg‐C 3 N 4 catalyst could be recycled easily without significant loss of catalytic activity, which is demonstrate by the recyclability of HPW/mpg‐C 3 N 4 catalyst test.