We show that semiconducting graphene nanoribbons (GNRs) of different width, edge, and end termination (synthesizable from molecular precursors with atomic precision) belong to different electronic topological classes. The topological phase of GNRs is protected by spatial symmetries and dictated by the terminating unit cell. We have derived explicit formulas for their topological invariants and shown that localized junction states developed between two GNRs of distinct topology may be tuned by lateral junction geometry. The topology of a GNR can be further modified by dopants, such as a periodic array of boron atoms. In a superlattice consisting of segments of doped and pristine GNRs, the junction states are stable spin centers, forming a Heisenberg antiferromagnetic spin 1/2 chain with tunable exchange interaction. The discoveries here not only are of scientific interest for studies of quasi-one-dimensional systems, but also open a new path for design principles of future GNR-based devices through their topological characters.