As a new kind of carbon material, graphene has unique two-dimensional (2D) structure and outstanding physicochemical properties, such as high electrical conductivity and large surface area (2675 m2/g). In recent years, graphene has exhibited great potential for application as electrode materials in supercapacitors. In this work, a layered graphic carbon nitride (g-C3N4) which was generated through polycondensation of melamine was employed as a 2D self-sacrificing template. Then, a nitrogen-doped graphene-like 2D carbon sheets (GLCS) was prepared by the calcination of melamine and terephthalaldehyde. This graphene synthesis method is a more facile and cost-effective route comparing with traditional synthetic methods, such as chemical exfoliation of graphite and chemical vapor deposition (CVD). In a typical synthesis, melamine was used as precursor of template and reactant of Schiff-base reaction. The g-C3N4 template was used to confine the as-formed polymer to the interlayer gaps at about 600 ℃. Then, as the temperature continued to rise, the g-C3N4 template undergoes complete thermolysis and the polymer between interlayer gaps was carbonized to be GLCS. Then, after activated by KOH, a porous a-GLCS with high specific surface area and pore volume was obtained. GLCS and a-GLCS were characterized by transmission electron microscopy (TEM), scanning electron microscopy (SEM), X-ray photoelectron spectroscopy (XPS), Brunauer-Emmett-Teller (BET) surface area measurement, Raman spectroscopy etc. TEM and SEM results showed that GLCS showed well-defined two-dimensional structure, XPS analysis determined the nitrogen-containing functional groups present on the surface of the sample, BET surface area measurement showed that after activated by KOH, the surface area have been obviously improved from 262.8 m2/g to 478.5 m2/g. The electrochemical measurement showed that, at the current density of 1 A/g, the specific capacitance of GLCS and a-GLCS are 150 and 300 F/g respectively. When the current density increased up to 20 A/g the specific capacitance remained 100 and 200 F/g respectively. The increasing of the specific capacitance was considered to be due to the generation of microporous during the activation process.