Carbon-based materials are promising alternatives to noble metal catalysts, but their structures are typically disordered and difficult to control. Here, the authors obtain ordered carbonaceous frameworks with advantageous electrocatalytic properties via the carbonization of nickel-containing porphyrin dimer networks.