Recently, Zacharias et al [Phys. Rev. Lett. 115, 177401 (2015)] developed a new ab initio theory of temperature-dependent optical absorption spectra and band gaps in semiconductors and insulators. In that work the zero-point renormalization and the temperature dependence were obtained by sampling the nuclear wavefunctions using a stochastic approach. In the present work, we show that the stochastic sampling can be replaced by fully deterministic supercell calculations based on a single optimal configuration of the atomic positions. We demonstrate that a single calculation is able to capture the temperature-dependent band gap renormalization including quantum nuclear effects in direct and indirect-gap semiconductors, as well as phonon-assisted optical absorption in indirect-gap semiconductors. In order to demonstrate this methodology we calculate from first principles the temperature-dependent optical absorption spectra and the renormalization of direct and indirect band gaps in Si, C, and GaAs, and we obtain good agreement with experiment and with previous calculations. In this work we also establish the formal connection between the Williams-Lax theory of optical transitions and the related theories of indirect absorption by Hall, Bardeen, and Blatt, and of temperature-dependent band structures by Allen and Heine. Furthermore, we identify an additional band gap renormalization that arises in the case of degenerate band extrema, and which has not been considered in previous work. The present methodology enables systematic ab initio calculations of optical absorption spectra at finite temperature, including both direct and indirect transitions. This feature will be useful for high-throughput calculations of optical properties at finite temperature, and for calculating temperature-dependent optical properties using high-level theories such as GW and Bethe-Salpeter approaches.