Silicon (Si) is regarded as one of the most promising lithium-ion battery anodes to replace commercial graphite due to its exceptional theoretical capacity, appropriate voltage profile, environmental friendliness and natural abundance. It is crucial to develop effective strategies to improve the cyclic performance of the Si anodes. A new concept to synthesize Si/carbon composite with three dimensional (3D) hierarchical macro-/mesoporous structure is reported. Stöber silica (SiO2) particles are used as templating agent and precursor for Si simultaneously. Unlike conventional work reported previously, here the silica particles are composited with carbon matrix before magnesiothermic reduction. Difunctional methacrylate monomers are used as solvent and carbon source coupled with a fast, environmental friendly and energy saving photo polymerization to prepare the SiO2/C composite. Based on a self-templating mechanism during the magnesiothermic reduction process, 3D hierarchical macro-/mesoporous Si is formed in situ within the carbon matrix. Compared to the Si/carbon composite composed of micro-sized Si and bare macro-/mesoporous Si, the cyclic performance is significantly improved with a reasonable mass loading density. Good rate performance is exhibited comparable to the bare porous Si. The hierarchical macro-/mesoporous structure within the carbon matrix helps to retain the porous Si structure, which effectively improves the electrochemical performance.