Direct ink writing (DIW) of geopolymers with desirable patterns, compositions, and properties holds great promise for sustainable concrete, porous adsorbent, and high-temperature ceramic. However, precisely constructing geopolymers by DIW is subject to the low viscosity of geopolymer inks and the limited choice of alkali metal ions. Here, we realize the production of high-quality geopolymer by adding suitable additives, where the modified Na-, K-, and Cs-based geopolymer inks show high yield stresses of 1002 Pa, 1590 Pa, and 165 Pa, respectively. The optimized rheological properties enable DIW of geopolymers with complex patterns, high spatial resolution, and controllable mechanical properties. Furthermore, we reveal the mechanism underlying the fracture behaviors of the 3D-printed geopolymers combining compression tests, theoretical models, and FEM analysis. Our results pave the way for designing high-quality geopolymer-based materials, which are critical for industrial applications and sustainable development.