A thermal nitridation route for the assembly and polymerization of molecular triazine units to heptazine-based covalent frameworks has been successfully established. The obtained conjugated carbon nitride polymers feature nanostructures that show enhanced photocatalytic reactivity for hydrogen production under visible light irradiation.