Phenylene–ethynylene monomer and copolymer bearing pendant imidazolium groups were synthesized in order to obtain luminescent entities highly soluble in ionic liquids (ILs). Their stabilities under non-aqueous sol–gel conditions (i.e. using formic acid) allowed their incorporation into silica in the form of ionogels. This was performed in a one step synthesis and the resulting materials were found to be easily processable as monoliths and showed interesting luminescent properties. Given the high solubility of 2,4-dinitrotoluene in the investigated IL, (1-butyl-3-methylimidazolium bis(trifluoromethylsulfonyl)imide), the relevance of these ionogels as luminescent sensors was tested.