  We study minimal and toroidal compactifications of $p$-integral models of
Hilbert modular varieties. We review the theory in the setting of Iwahori level
at primes over $p$, and extend it to certain finer level structures. We also
prove extensions to compactifications of recent results on Iwahori-level
Kodaira--Spencer isomorphisms and cohomological vanishing for degeneracy maps.
Finally we apply the theory to study $q$-expansions of Hilbert modular forms,
especially the effect of Hecke operators at primes over $p$ over general base
rings.
