The template is first printed on the glass. This is done by putting a light sensitive layer (photoresist) on the glass, and exposing some of it to light. When the light gets put on there the properties of the photoresist change so you can wash off the parts you don't want. Jl6 called this process "etching" (there may be additional steps that can also be described as etching, I don't know. Semiconductors are made with a lot of processes. This is the most well known process).
Then you spray on the chemicals you want, and then you wash away the remaining photoresist so you can put the next layer on.
This happens a lot of times for a modern chip.
[1]: https://en.wikichip.org/wiki/mask
[2]: https://en.wikipedia.org/wiki/Electron-beam_lithography
https://en.wikipedia.org/wiki/Wafer_fabrication
Here is ASML specifically, in a very slow slideshow format, representing our finest web technology.
https://www.asml.com/en/technology/all-about-microchips/how-...
The wavelength, or the color of the light here limits how much minified image we can shine and currently the Extreme ultraviolet lithography(EUV) is the state of the art where they use ultraviolet light with 13.5nm wavelength. As different materials behave differently under different light wavelengths, EUV requires different process to shine the mask over the silicon disk. One major difference from the previous processes is that in EUV lithography they use mirrors instead of lenses to direct the light.
So far, it's only the European manufacturer ASML who managed to perfect this process for mass production.