Elucidating the impact of heteroatoms in graphitic carbon nitrides (g‐C3N4) is of utmost importance to rationalize materials. Hence, in this study, oxygen‐doped g‐C3N4 containing trace amounts of halogen in the structures for piezo‐photosynthesis of hydrogen peroxides (H2O2) is fabricated. The findings reveal that oxygen atoms may be inserted into g‐C3N4 in‐plane structures, while halogen atoms tend to become intercalated between g‐C3N4 layers. Furthermore, the presence of ammonium molten salts (NH4X) during the synthesis alters the concentration of mono and cluster vacancies of carbon and nitrogen in the materials, certifying by positron annihilation spectroscopy (PAS). These defective contributions will be meaningfully accelerate catalytic performance by providing trapping states. Additionally, the decomposition of generated H2O2 can produce highly oxidative hydroxyl radicals, inducing degradations on the catalyst's structures and unexpectedly decreasing catalytic outcomes. From the mechanistic view, different reduction and oxidation channels will be play a pivotal role in generating H2O2. Moreover, the influence of ultrasound and light is also carefully investigated in the work to gain more insights into how the catalysts are triggered to improve catalytic performance. Thus, this study highlights the importance of carefully characterizing structures of g‐C3N4 to precisely understand the catalytic properties, benefiting catalytic design and development.