We propose a generalization of a Drinfeld–Sokolov scheme of attaching integrable systems of PDEs to affine Kac–Moody algebras. With every affine Kac–Moody algebra \(\mathfrak{g} \) and a parabolic subalgebra \($$\) , we associate two hierarchies of PDEs. One, called positive, is a generalization of the KdV hierarchy, the other, called negative, generalizes the Toda hierarchy. We prove a coordinatization theorem which establishes that the number of functions needed to express all PDEs of the the total hierarchy equals the rank of\(\mathfrak{g} \) . The choice of functions, however, is shown to depend in a noncanonical way on \($$\). We employ a version of the Birkhoff decomposition and a ‘2-loop’ formulation which allows us to incorporate geometrically meaningful solutions to those hierarchies. We illustrate our formalism for positive hierarchies with a generalization of the Boussinesq system and for the negative hierarchies with the stationary Bogoyavlenskii equation.