Covalent organic frameworks (COFs) have potential applications in a wide range of fields. However, it remains a critical challenge to constrain their covalent expansions in the one-dimensional (1D) direction. Here, we developed a general approach to fabricate 15 different highly crystalline COFs with zigzag-packed 1D porous organic chains through the condensation of V-shaped ditopic linkers and X-shaped tetratopic knots. Appropriate geometrical combinations of a wide scope of linkers and knots with distinct aromatic cores, linkages, and functionalities offer a series of quasi-1D COFs with dominant pore sizes of 7-13 Å and surface areas of 116-784 m2 g-1. Among them, nitrogen (N)-doped 1D COFs with site-specific doping of heteroatoms favor a tunable control of band structures and conjugations and thus allow a remarkable hydrogen evolution rate up to 80 mmol g-1 h-1 in photocatalytic water splitting. This general strategy toward programming function in porous crystalline materials has the potential to tune the topologically well-defined electronic properties through precisely periodic doping.