Herein, a heterogeneous carbon–nitrogen heterojunction g-C3N4-C2N (CC) is constructed by embedding electrophilic hexaazatriphenylene (HAT) into the heptazine framework of graphitic carbon nitride (g-C3N4) through in-plane fusing. The similar chemical compositions and molecular structures between g-C3N4 and C2N derived from HAT allow for great compatibility in co-planarly grafting. Electrochemical tests and theoretical calculations show that after co-planar grafting with C2N, g-C3N4 forms a typical donor–acceptor relationship with it. The photoinduced electrons generated by the excitation of the composite would converge to C2N, effectively enhancing the separation of electron-hole pairs. Moreover, oxygen-doped g-C3N4-C2N (CC-O) is obtained by the introduction of oxygen-containing functional groups, and the CO2 adsorption performance is further optimized. In the absence of any co-catalyst, photosensitizer or organic sacrificial agent, the photocatalytic reduction of CO2 to CO on the oxygen-doped polymer CC-O0.2 exceeded a yield of 28.64 μmol g-1h−1 with a selectivity of 99 %. Furthermore, the reaction site for photoconversion and the reason for different photocatalytic efficiency are revealed. The strategy of synergizing the two modification methods in this work offers more possibilities for the rational design of organic polymers for light-driven carbon neutralization.