Sulfur-doped carbon xerogels were obtained through carbonization of resorcinol/2-thiophenecarboxaldehyde organic gels. The acid-catalyzed sol–gel polymerization of resorcinol and 2-thiophenecarboxaldehyde leads to organic gels whose morphology and texture is dependent on the amount of catalyst used. As a result, monolithic organic gels with sulfur content of up to 19.6wt.% and easily tailored properties can be produced. After carbonization, a substantial amount of sulfur is retained and porous carbon xerogels with S-content of up to 10wt.% are produced (at 800°C). Depending on the sol–gel synthesis conditions, monolithic S-doped carbon xerogels with controllable and enhanced mesoporosity, surface areas of up to 670m2/g and enhanced mechanical integrity were obtained. Additional KOH activation of the organic or carbon xerogels enables production of micro–mesoporous carbons with surface areas of up to 2550m2/g while retaining over 5wt.% of sulfur. Preliminary CO2 adsorption measurements were performed. On the basis of resorcinol/2-thiophenecarboxaldehyde gel synthesis a more general approach towards heteroatom-doped carbon gels is proposed: sol–gel polymerization of phenols and heterocyclic aldehydes. Thus a variety of heteroatom-doped porous carbon materials with a tailored pore texture and morphology are available via this procedure.