Li–S batteries are positioned as a strong alternative for efficient energy storage due to their high theoretical energy density and their theoretical specific capacity (1675 mA h g−1) compared to current Li-ion batteries; however, their commercialization is affected by the rapid decay of the specific capacity as a consequence of the different species of lithium polysulfides that are generated during the charge–discharge processes. The use of nitrogen-doped mesoporous carbon materials has been shown to have the ability to confer electronic conductivity to sulfur and retain the lithium polysulfide species. However, there are not enough studies to help understand how the type of nitrogen precursor influences the development of specific nitrogen functionalities to favor the retention of lithium polysulfide species. This work seeks to determine the effect of the use of different nitrogen precursors on the structural changes of the mesoporous carbon materials prepared, and thus evaluate the electrochemical behavior of Li–S cells correlating the type of nitrogen functionality generated when the precursor is variated with the charge/discharge capacity developed during the cell operation. For this study, different carbon materials were prepared by the variation of the nitrogen source (melamine, ethylenediamine, and hexadecylamine) to obtain a N-doped mesoporous carbon with different distributions of nitrogen functionalities in its structure. The use of the primary amine ethylenediamine as a nitrogen precursor in the formation of structured carbon materials favored elemental sulfur infiltration into its pores, resulting in the maximum sulfur content within the pores and interacting with the carbonaceous matrix (78.8 wt.%). The carbon material prepared with this precursor resulted in a higher content of N-pyridinic functionality, which, combined with the high content of N-pyrrolic, resulted in the highest specific discharge capacity at 0.1 C after 100 cycles when compared to cells assembled with materials derived from the use of melamine and hexadecylamine precursors. The cell assembled with the electrode formed from ethylenediamine as a nitrogen precursor presented an initial discharge capacity of 918 mA h g−1 with a Coulombic efficiency of ~83.4% at 0.1 C after 100 cycles.