Electrochemical nitrogen reduction reaction (NRR) to produce ammonia under ambient conditions is considered as a promising approach to tackle the energy-intensive Haber-Bosch process,but the low Faradaic efficiency and yield of NH3 are still a challenge.Herein,a carbon-vacancies enriched mesoporous g-C3N4 is developed by an in situ Zr doping strategy.The in situ mesoporous-forming mechanism is deeply understood by TPSR to reveal the functions of Zr dopant that pulls C from the precursor of C3N4,resulting the formation of homogeneous mesopores with about 57% of the one C-defective s-triazine ring in C3N4.Due to the defect sites obtained in metal doping synthesis,the RuAu bimetallic supported catalyst (RuAu3/0.3Zr-C3N4) exhibits effective NRR performance with a Faraday efficiency of 11.54% and an NH3 yield of 5.28 μg h-1 mg-1cat.at-0.1 V (RHE),which is nearly 10 times higher than that of RuAu3/C3N4 catalyst.This work proposes a simple and template-free preparation method for the high defect density mesoporous C3N4,and provides new possibilities of a wide application of mesopore g-C3N4.