The production of hydrogen via electrocatalytic reduction of water using metal-free nanomaterials as the catalyst is a promising and ultimate green approach. Graphitic carbon nitride, covalent organic frameworks, and covalent triazine frameworks (CTFs) are some of the nanostructured materials that are investigated for this purpose. Currently, these materials still lack the efficiency to compete with other techniques (electrolysis). This is because the reaction mechanism and active sites are, in many cases, still poorly understood. In this work, we report a set of metal-free nanostructure-based electrocatalysts, phosphorus covalent triazine frameworks (PCTFs), for electrocatalytic hydrogen production. The hydrogen evolution reaction (HER) performance of PCTF-based nanomaterials is ascribed to the synergistic effect of isolated single nitrogen and phosphorus sites on the large surface area. By combining both experimental and theoretical studies, we found that especially the pyridinic-nitrogen species are the most active sites for the HER. The presence of phosphorus next to the pyridinic-N enhances the HERs. The present results provide a better understanding of the importance of different heteroatoms in nanomaterials as active sites in HERs. Theoretical studies confirmed that phosphorus, being electron rich, creates high electron densities on the nearby N atoms of the CTF materials and intensifies the HER process.