The bandgap of hydrogenated amorphous silicon (a-Si:H) is studied using a unique set of a-Si:H films deposited by means of three different processing techniques. Using this large collection of a-Si:H films with a wide variety of nanostructures, it is demonstrated that the bandgap has a clear scaling with the density of both hydrogenated divacancies (DVs) and nanosized voids (NVs). The presence of DVs in a dense a-Si:H network results in an anisotropy in the silicon bond-length distribution of the disordered silicon matrix. This anisotropy induces zones of volumetric compressed disordered silicon (larger fraction of shorter than longer bonds in reference to the crystalline lattice) with typical sizes of ~0.8 up to ~2 nm. The extent of the volumetric compression in these anisotropic disordered silicon zones determines the bandgap of the a-Si:H network. As a consequence, the bandgap is determined by the density of DVs and NVs in the a-Si:H network.