Abstract Porous carbon nitrides of different morphology were obtained via bulk and hard template (SBA-15 and MCF) pyrolysis of melamine. Matrix method allowed obtaining ordered porous C 3 N 4 with higher bandgap (2.87 eV) in the contrary to the bulk sample (2.45 eV). Obtained carbon nitrides were found to be p-type semiconductors with catalytic activity towards photoreduction of carbon dioxide with water vapour. Carbon nitride obtained in MCF has the higher bandgap, developed surface, sponge-like morphology, spatially ordering and it's characterized by the highest photocatalytic activity.