N, S-co-doped hierarchical porous carbon with stable sodium storage were prepared by designing the precursors and changing the reaction temperature.