Mesoporous and microporous silica matrices were formed on indium tin oxide electrodes for liquid-phase voltammetry and as monoliths for solid-state voltammetry of aniline. The pore structure, which was verified by scanning probe microscopy and by surface area measurement, was directed by either control of pH during sol–gel processing or by inclusion of a templating agent. Whether aniline was included as a dopant in the sol–gel or as a component of the contacting liquid, the pore size influenced the coupling of the product of its electrochemical oxidation. With microporous silica, the dominant products were dimers and related short-chain products whereas with mesoporous silica, polymerization was suggested. As a step toward the formation of polyaniline (PANI) that is covalently anchored to the sol–gel, the electrochemistry of aniline was investigated using composites prepared from sols comprising tetraethyl orthosilicate (TEOS), 3-aminophenyl-[3-triethoxylsilyl)-propyl] urea (ormosil), and aniline in various ratios. Combinatorial chemistry identified that the optimum combination of silica precursors in terms of obtaining PANI was a 1:12 mole ratio of ormosil:TEOS.