Abstract As a serious threat to environmental safety and public health, mercury ((Hg 2+ ) has been noted as a global hazard because of its high toxicity. Recently, significant effort has been invested in developing novel strategies for simultaneous detection and remove of Hg 2+ . Herein, we designed and synthesized three types of nitrogen-, oxygen- and sulfur-rich covalent organic polymers (COPs) for Hg 2+ detection and adsorption from solutions. For comparison, the aldehydes building blocks containing one, two, or three thiophene rings condensed with the flexible hydrazide terephthalate to obtain the COPs named as HTDP-1, HTDP-2 and HTDP-3, respectively. With electron rich thiophene-bicyclic systems, the HTDP-2 exhibited a fast adsorption capacity for Hg 2+ (91.2% within 10 min). In addition, the polymer also has excellent fluorescence properties, which can realize the fluorescence detection of Hg 2+ in a with a detection limit of 0.70 ppm. This work provides a novel design concept for the rational construction of dual-function Hg 2+ repair materials and broadens the application of COPs materials in the field of heavy metal ions detection and repair.