: Poly(heptazine imide) (PHI) has attracted extensive attention in photocatalytic hydrogen evolution owing to its suitable band structure and unique ionic framework. However, the photocatalytic performance of PHI is still limited by inefficient interlayer charge transport. In this work, Mg 2+ was successfully incorporated into the interlayer of PHI through a facile ion-exchange strategy using an aqueous MgCl 2 solution. Compared with conventional defect-engineering strategies, the metal-ion modification in a relatively defect-free PHI framework enables the investigation of the intrinsic role of metal ions in regulating charge transport while avoiding the interference from defect-induced deep trap states. The incorporated Mg species facilitate interlayer charge migration, significantly promoting carrier transport without introducing additional recombination centers. As a result, the optimized Mg-PHI photocatalyst achieves an enhanced hydrogen evolution rate of 9520 μmol h -1 g -1 under visible-light irradiation (λ > 420 nm), which is 4.17 times higher than that of pristine PHI. This work provides new insights into rational metal-ion engineering for highly efficient PHI-based photocatalysts.