Ring-opening polymerization affords an extremely powerful driver for large-scale delocalization of π-electrons and good charge transport via incorporating aromatic repeat units and rigid molecular skeleton. Herein, we first developed a branched six functional benzoxazine monomer (BZ) through Mannich condensation reaction. The rigid chain segment structure of crosslinked polybenzoxazine (PBZ) penetrated into the π-conjugated planes of C3N4 via the room-temperature HCl-catalyzed polymerization of the monomer, leading to the formation of a range of 3D C3N4 monolithic aerogels embedded with carbon aerogel. High nitrogen self-doped carbon aerogels were flexibly embedded in situ into the C3N4 matrix during the heat curing process, leading to the redshift of the C3N4 absorption edge and the increase of electrical conductivity. The special framework of the NC/C3N4 monolithic aerogels can tremendously enrich the electron-trapping sites through the generation of delocalized big π bonds. This work provides new insights into the understanding of polymer chemistry and photocatalysis mechanism.