It remains a challenge to induce robust long-range ferromagnetism in graphene. Doping nitrogen in high concentration is considered as a potential approach. In this paper, three new graphitic carbon nitride structures with energetic stability in chemical formulae of C10N6, C9N7 and C7N9 are proposed and investigated by first-principles calculation. Both C10N6 and C9N7 are half-metals, and C7N9 is a spin-polarized metal. The itinerant p electrons occupy the spin-polarized narrow bands near the Fermi level, which induces Stoner ferromagnetism in the C10N6 and C9N7. The direct exchange between the delocalized magnetic moment of the itinerant π electrons is responsible for the ferromagnetism in the C7N9. The magnetic moment is determined by both spin-polarized electronic structures and long-range magnetic interaction. Intriguingly, besides the magnetic interactions between the itinerant π electrons, we also find direct magnetic interaction between localized in-plane unpaired electrons. Our results will assist in understanding ferromagnetism and motivate new experiments to produce robust magnetism in graphene-like materials following the proposed synthesis strategy.