Doping heteroatoms into carbon nanomaterials will greatly enhance their physiochemical properties, however, it is still challenging to prepare doped nanocarbons in large-scale by economical ways for industrial applications. Here, we report the macroscopic-scale synthesis of a new class of nitrogen-doped carbonaceous nanofibers (N-CNFs) aerogels with diameter from tens to hundreds nanometers by a template-directed hydrothermal carbonization (HTC) process, where ultrathin tellurium nanowires (TeNWs) as templates and nitrogen-containing carbohydrates as carbon sources. High-temperature treatment and CO2 activation of the N-CNFs endow them with high conductivity and porosity, resulting in outstanding performances as electrode materials for electrocatalysts and supercapacitors.