The fast massive sublimation of small N-rich monomers due to poor thermal stability for carbon nitride (CN) material synthesis based on the supramolecular assembly technique usually causes defects and insufficient integrity that inhibit charge migration for a better photoactivity. Herein, we introduced a highly thermally stable supramolecular assembly of C-doped melem with HCl for the controllable synthesis of a C-doped porous CN material. The structure of the supramolecular assembly is evidenced via DFT calculations and various characterization studies. The dense H-Cl bonds and highly thermally-stable heptazine-based supramolecular assembly restrict fast massive sublimation, enabling CN with a faster photogenerated charge migration ability on the more ordered skeleton structure, and an enhanced redox ability originating from controlled C-substituted N positions that leads to a tailored band structure. The optimal CN catalyst shows a desirable activity in the H2 evolution reaction (HER) via photocatalytic water splitting, with an HER rate of 2316.3 μmol h-1 g-1 (11.4 times that of bulk CN), an AQE value of 16.0% at 405 nm, and excellent cycling performance without noticeable decay after 5 reuses.