Nanosized and highly dispersed molybdenum carbide was fabricated in the carbon walls, along with the formation of ordered mesoporous carbons, via a one-pot organic-organic cooperative self-assembly approach.