Oxygen-doped carbon nitride aerogel (OCNA) was successfully fabricated through a facile self-assembly method combined with hydrothermal process, without adopting any harmful solvents or cross-linking agents. The assembly mechanism of carbon nitride aerogel (CNA) with different morphologies was discussed. OCNA exhibited much faster charge separation efficiency, longer carriers' lifetime than bulk carbon nitride (BCN). More importantly, oxygen-doping adjusted the band structure of carbon nitride, leading to a more negative conduction band (CB) position and narrower band gap (Eg). The spectral response range of OCNA was extended greatly and the hydrogen evolution rate (HER) of OCNA (λ > 510 nm) was about 26 times as high as that of BCN prepared herein. The apparent quantum yield (AQY) was 20.42% at 380 nm, 7.43% at 420 nm and 1.71% at 500 nm. This work paves a facile colloid chemistry strategy to assemble 3D CAN that could be widely adopted in the sustainability field.