A nitrogen‐rich porous inorganic–organic hybrid polymer, TMPS, was successfully synthesized by Friedel–Crafts arylation with anhydrous aluminum trichloride as a catalyst, which has good sensitivity to nitro‐aromatic compounds. The material was systematically characterized by using FT‐IR, solid‐state 13C NMR, elemental analysis, powder X‐ray diffraction, solid‐state UV–Vis, and so forth. The thermogravimetric analysis experiments confirmed that TMPS has very good thermal stability. Its Brunauer Emmett Teller specific surface area measured by nitrogen adsorption desorption experiment is 115 m2 g−1. Due to its excellent conjugated structure and nitrogen‐rich features, TMPS exhibits a very high sensitivity and selectivity to 2,4‐dinnitrophenol. Based on the data obtained from the fluorescence detection experiment, the KSV and limit of detection are 1.84 × 104 L mol−1 and 1.63 × 10−11 mol L−1, respectively. Therefore, TMPS can act as a fast and sensitive fluorescent sensor to detect DNP.