Porous materials synthesized through bottom-up approaches, such as metal-organic frameworks and covalent organic frameworks, have attracted attention owing to their design flexibility for functional materials. However, achieving the chemical and thermal stability of these materials for various applications is challenging considering the reversible coordination bonds and irreversible covalent bonds in their frameworks. Thus, ordered carbonaceous frameworks (OCFs) emerge as a promising class of bottom-up materials with good periodicity, thermal and chemical stability, and electrical conductivity. However, a few OCFs have been reported owing to the limited range of precursor molecules. Herein, we designed a hexaazatrinaphthylene-based molecule with enediyne groups as a precursor molecule for synthesizing an OCF. The solid-state Bergman cyclization of enediyne groups at a low temperature formed a microporous polymer and an OCF, exhibiting redox activity and demonstrating their potential for electrochemical applications. The microporous polymer was used as an active material in sodium-ion batteries, while the OCF was used as an electrochemical capacitor. These findings illustrate the utility of the Bergman cyclization reaction for synthesizing microporous polymers and OCFs with a customizable functionality for broad applications.