Abstract The intrinsic charge carriers’ recombination and excited states decay greatly suppress the active species survival and photo(electro)catalytic performance. Inspired by Z‐scheme strategy, the polymeric nitrogen‐rich carbon nitride/cadmium sulfide (g‐C3N5/CdS) core–shell heterojunction is constructed to optimize photocatalytic performance. The optimal hydrogen production rate of g‐C3N5/CdS heterojunction catalyst under visible light without adding extra cocatalyst is up to 7860 µmol h−1 g−1, which is 3 and 71 times higher than that of pure CdS and g‐C3N5 photocatalysts, respectively. The femtosecond transient absorption spectroscopy is employed to observe the kinetic decay of carriers in the heterojunction, revealing the ultrafast charge trapping process (τ1 = 52.3 ps) and long‐lived excited states (τ3 = 1109.2 ps) in g‐C3N5/CdS photocatalyst. Meanwhile, density functional theory calculation results comprehensively suggest the promoted charge separation in heterojunction. Cost‐effective Z‐scheme g‐C3N5/CdS photocatalyst in this work shows a great potential for sustainable and high‐efficiency solar‐to‐H2 conversion.