Solar photocatalytic hydrolysis of hydrogen is one of the most important ways to solve energy and environmental problems. Rational design and modulation of interfaces in S-scheme heterojunctions still present significant challenges for solar hydrogen production. Herein, a novel 2D/3D hierarchical graphdiyne/CoAl2O4 (GCA) S-scheme heterojunction was successfully constructed by coupling graphdiyne (GDY) nanosheets onto porous CoAl2O4 nanoflowers. GDY was synthesized by a cross-coupling reaction and ultrathin 3D porous CoAl2O4 nanoflowers were transformed from CoAl-LDH. This unique 3D hierarchical porous structure of CoAl2O4 nanoflowers not only provides a larger specific surface area, sufficient active sites and enhanced light harvesting, but also significantly reduces the aggregation of GDY. Notably, hierarchical GCA-15 shows an exceptional photocatalytic hydrogen production rate of 5009.28 μmol g−1 h−1 under visible-light irradiation, which was 4.78 times higher than that of pristine CoAl2O4. This excellent photocatalytic activity can be attributed to the synergistic effect of the formed S-scheme heterojunction between GDY and CoAl2O4 and the 2D/3D hierarchical architecture. In situ irradiated XPS, UPS and DFT unveil the S-scheme electron transfer for GDY/CoAl2O4. The work functions and charge density difference further indicate the electrons transferring from GDY to CoAl2O4. This work provided a simple strategy for designing and constructing hierarchical graphdiyne-based S-scheme heterostructures for photocatalytic hydrogen production.