Carbon nitrides are among the most studied materials for photocatalysis, however, limitations arise from inefficient charge separation and transport within the material. Here, this aspect is addressed in the 2D carbon nitride poly(heptazine imide) (PHI) by investigating the influence of various counterions, such as M = Li+, Na+, K+, Cs+, Ba2+, NH4+ and tetramethyl ammonium, on the material’s conductivity and photocatalytic activity. These ions in the PHI pores affect the stacking of the 2D layers, which further influences the predominantly ionic conductivity in M-PHI. Na-containing PHI outperforms the other M-PHI in various relative humidity (RH) environments (0-42 %RH) in terms of conductivity, likely due to pore channel geometry and size of the (hydrated) ion. With increasing RH, the ionic conductivity increases by 4-5 orders of magnitude (for Na-PHI up to 10-5 S cm-1 at 42 %RH). At the same time, the highest photocatalytic hydrogen evolution rate is observed for Na-PHI, which is mirrored by increased photo-generated charge carrier lifetimes, pointing to efficient charge carrier stabilization by mobile ions. These results indicate that ionic conductivity is an important parameter that can influence the photocatalytic activity. Besides, RH-dependent ionic conductivity is of high interest for separators, membranes, or sensors.