A novel method is developed for constructing well-defined N-doped graphdiyne (GDY) nanostructures. This method can effectively tune the N-configurations (pyridinic N and triazine-like N cluster), N-content, and porous structures of GDYs, indicating good controllability. The N-configurations and structure of GDYs are well confirmed by the X-ray photoelectron spectrometer measurements, nitrogen absorption measurements and neutron pair distribution function (PDF), respectively. The as-prepared GDYs can be assembled into high-performance two-electrode supercapacitors with specific capacitance high up to 250Fg−1, delivering an energy density of 8.66Whkg−1 and power density of 19.3kWkg−1; the well-defined N-configuration in GDYs offers us an opportunity to understand the controversial nitrogen role in catalyzing the oxygen reduction reaction in sp2 carbons. Importantly, this method for creating well-defined N-doped GDYs may widely extend the GDY materials for new energy fields.