The construction of heterojunctions provides a promising strategy to improve photocatalytic hydrogen evolution. However, how to fabricate a nanoscale TiO2/g-C3N4 heterostructure and hinder the aggregation of bulk g-C3N4 using simple methods remains a challenge. In this work, we use a simple in situ construction method to design a heterojunction model based on molecular self-assembly, which uses a small molecule matrix for self-integration, including coordination donors (AgNO3), inorganic titanium source (Ti(SO4)2) and g-C3N4 precursor (melamine). The self-assembled porous g-C3N4 nanotube can hamper carrier aggregation and it provides numerous catalytic active sites, mainly via the coordination of Ag+ ions. Meanwhile, the TiO2 NPs are easily mineralized on the nanotube template in dispersive distribution to form a heterostructure via an NāTi bond of protonation, which contributes to shortening the interfacial carrier transport, resulting in enhanced electron-hole pairs separation. Originating from all of the above synergistic effects, the obtained Ag/TiO2/g-C3N4 heterogenous photocatalysts exhibit an enhanced H2 evolution rate with excellent sustainability 20.6-fold-over pure g-C3N4. Our report provides a feasible and simple strategy to fabricate a nanoscale heterojunction incorporating g-C3N4, and has great potential in environmental protection and water splitting.