Photocatalytic overall water splitting (H2/O2 = 2) on graphitic polymeric carbon nitride (g-C3N4) is still a challenge due to the presence of an insufficient number of active sites and the weak oxidative capacity of the valence band towards H2O. Herein, a 3D porous g-C3N4 photocatalyst was prepared by the SiO2 hard template method, and overall water splitting was achieved with a Z-scheme system. With the confinement effect of SiO2, 3D porous g-C3N4 possesses a large specific area and thin walls compared to bulk g-C3N4, which not only provides more active sites but also shortens the charge migration distance, thus enhancing the photocatalytic activity. With a specific surface area of 159.7 m2·g−1 and a 12.4 nm pore size, the mesoporous g-C3N4-15 showed the highest H2 evolution rate, reaching 2.5 (under full-wavelength light: λ > 320 nm) and 4.7 (under visible light: λ > 420 nm) times that of bulk g-C3N4. Under a Z-scheme system where BiVO4 and Fe2+/Fe3+ are used as the O2 evolution photocatalyst and carrier transfer mediator, respectively, the mesoporous g-C3N4-15 achieved overall water splitting under both full-wavelength (H2: 81.6 μmol∙h−1, O2: 40.4 μmol∙h−1) and visible (9.8 μmol∙h−1 and 4.4 μmol∙h−1) light irradiation with 1.8% apparent quantum yield (AQY) at λ = 420 nm. Besides high photocatalytic activity, the large specific surface area of g-C3N4-15 is beneficial for the adsorption and redox capability of Fe2+/Fe3+, which facilitates the formation of the Z-scheme system and promotes the photocatalytic activity.