In this present study, a series of cobalt porphyrin-based conjugated mesoporous polymers (CoP-nph-CMP, n = 2, 3, 4) were fabricated as catalyst precursors to generate bifunctional catalysts via pyrolysis (CoP-nph-CMP-800, n = 2, 3, 4) for both the oxygen evolution reaction (OER) and the hydrogen evolution reaction (HER). Among these catalysts, CoP-2ph-CMP-800 exhibited the best catalytic activity with quite a low overpotential for both the OER (η = 370 mV for 10 mA cm-2) and the HER (η = 360 mV for 10 mA cm-2). Moreover, their excellent bifunctional catalytic performance was also explored in the overall water splitting test (η = 760 mV for 10 mA cm-2).