π-Electrons have been successfully connected to an oxygen-doped porous carbon nitride by one-pot pyrolysis of the mixture of urea, ethanol, and 4-iodobenzaldehyde (IBD) in the atmosphere. The resulting COCN 20 exhibits superior photocatalytic hydrogen production up to 6.88 mmol h −1 g cat −1 with a relatively high apparent quantum efficiency (20.6% at 325 nm) as well as toluene oxidation with an outstanding conversion rate of 3.75 mmol h −1 g cat −1 under 460 nm irradiation. Other π-electrons from aromatic heterocycles could also be grafted to the network for the general synthesis, demonstrating higher hydrogen evolution rates (e.g., 9.32 mmol h −1 g cat −1 with the thiophene-π-electrons coupling). The enhanced n → π* electron transition and activated midgap states are found to extend the light-responsive region and improve the capture of effective electrons, while the novel porous architecture encourages the efficient mass-transfer rate and improves light harvesting. This work showcases a straightforward and scalable approach to fabricate immensely proficient photocatalysts composed of porous carbon nitride. Furthermore, it opens up a novel pathway for the methodical development and production of sophisticated photocatalysts that harness the powerful synergistic effects achieved by simultaneously adjusting and refining the electronic, surface, and molecular structures.