Capsules are long-chain carbohydrate polymers that envelop the surfaces of many bacteria, protecting them from host immune responses. Capsule biosynthesis enzymes are potential drug targets and valuable biotechnological tools for generating vaccine antigens. Despite their importance, it remains unknown how structurally variable capsule polymers of Gram-negative pathogens are linked to the conserved glycolipid anchoring these virulence factors to the bacterial membrane. Using Actinobacillus pleuropneumoniae as an example, we demonstrate that CpsA and CpsC generate a poly(glycerol-3-phosphate) linker to connect the glycolipid with capsules containing poly(galactosylglycerol-phosphate) backbones. We reconstruct the entire capsule biosynthesis pathway in A. pleuropneumoniae serotypes 3 and 7, solve the X-ray crystal structure of the capsule polymerase CpsD, identify its tetratricopeptide repeat domain as essential for elongating poly(glycerol-3-phosphate) and show that CpsA and CpsC stimulate CpsD to produce longer polymers. We identify the CpsA and CpsC product as a wall teichoic acid homolog, demonstrating similarity between the biosynthesis of Gram-positive wall teichoic acid and Gram-negative capsules.