After substitution of carbon by nitrogen, the electronic structures of the porous graphene have been studied by the density functional theory calculations. The N substitutional site without hydrogen passivation leads to a tunable energy gap of the two-dimensional porous polymer, depending on the number of N atoms in a unit cell. Moreover, the increasing number of N in an aromatic ring enhances the binding energies between hydrogen molecules and pre-adsorbed Li atoms from 1H(2) to 3H(2). Thus, porous polymer materials through controllable synthesis techniques will improve their potential applications in photosplitting of water as well as hydrogen storage.