Broadening the visible light absorption range and accelerating the separation and migration process of charge carriers are effective ways to improve photocatalytic quantum efficiencies. In this study, we show that poly heptazine imides with enhanced optical absorption and promoted charge carrier separation and migration could be obtained by means of a rational design of the band structures and crystallinity of polymeric carbon nitride. Copolymerization of urea with monomers such as 2-aminothiophene-3-carbonitrile would first generate amorphous melon with enhanced optical absorption, while further ionothermal treatment of melon in eutectic salts would increase the polymerization degree and create condensed poly heptazine imides as final products. Accordingly, the optimized poly heptazine imide presents an apparent quantum yield of 12 % at 420 nm for photocatalytic hydrogen production.