The porous hybrid carbon and carbon nitride composites (C/CN‐P123‐x) with higher adsorption capacity and improved photocatalytic activity for methylene blue (MB) degradation were obtained using partially formaldehyde‐modified dicyandiamide and amphiphilic block polymers (P123) as precursor and soft‐template, respectively. The structures of as‐prepared composites were analyzed by thermogravimetric analysis, X‐ray diffraction, elemental analysis, nitrogen adsorption–desorption, scanning electron microscopy, transmission electron microscopy, photoluminescence spectroscopy, and X‐ray photoelectron spectroscopy. The effect of carbon content on the structure of the composites and the catalytic activity for the photodegradation of MB were determined under visible light. The optimal carbon content is determined to be 27.17 wt % on the C/CN‐P123‐0.8 with MB photodegradation rate of 0.0115 min−1, which was 1.92 times higher than that of C/CN‐P123‐0. The remarkably increased photocatalytic performance arises from the synergistic effect of hybrid carbon and graphitic carbon nitride. Also, the possible degradation mechanism of C/CN‐P123‐0.8 for MB was proposed. © 2019 American Institute of Chemical Engineers Environ Prog, 38:e13146, 2019