Lyα emission, Lyα absorption and Mgii absorption are powerful tracers of neutral hydrogen. Hydrogen is the most abundant element in the universe and plays a central role in galaxy formation via gas accretion and outflows, as well as being the precursor to molecular clouds, the sites of star formation. Since 21cm emission from neutral hydrogen can only be directly observed in the local universe, we rely on Lyα emission, and Lyα and Mgii absorption to probe the physics that drives galaxy evolution at higher redshifts. Furthermore, these tracers are sensitive to a range of hydrogen densities that cover the interstellar medium, the circumgalactic medium and the intergalactic medium, providing an invaluable means of studying gas physics in regimes where it is poorly understood. At high redshift, Lyα emission line searches have discovered thousands of star-forming galaxies out to z = 7. The large Lyα scattering cross-section makes observations of this line sensitive to even very diffuse gas outside of galaxies. Several thousand more high-redshift galaxies are known from damped Lyα absorption lines and absorption by the Mgii doublet in quasar and GRB spectra. Mg ii, in particular, probes metal-enriched neutral gas inside galaxy haloes in a wide range of environments and redshifts (0.1 < z < 6.3), including the so-called redshift desert. Here we review what observations and theoretical models of Lyα emission, Lyα and Mg ii absorption have told us about the interstellar, circumgalactic and intergalactic medium in the context of galaxy formation and evolution.