Simultaneously extended π-conjugated system and provide abundant pore structure of semiconductor photocatalysts for hydrogen (H2) production is highly desirable. Hence, a novel mesoporous sulfurized polyacrylonitrile modified g-C3N4 (g-C3N4/S-PAN) π-conjugation heterojunction is firstly fabricated by one-step strategy under the sulfur-induced cyclization reaction and pore-creating effect. Excitedly, the g-C3N4/S-PAN π-conjugation heterojunction extends the π-conjugated system in favor of speeding up the photogenerated electron transfer, which is due to strengthen the π-π interactions between the S-PAN and g-C3N4 and S-PAN is more apt to accept electrons. And the obtained g-C3N4/S-PAN π-conjugation heterojunction with mesoporous structure also provide abundant active sites for proton reduction. Accordingly, the g-C3N4/S-PAN-2 π-conjugation heterojunction shows the optimal photocatalytic H2 evolution (PHE) activity (736.24 μmol h−1g−1), which is approximately 2.15 times higher than pristine g-C3N4. In addition, the relationships of the optical and photoelectrochemical properties with photocatalytic activity are revealed in depth based on the first-principles calculations of band structure and density of states (DOS). This work provides a new one-step strategy to obtain g-C3N4-based π-conjugation heterojunction with the unique microstructure for improving PHE activity.