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.
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-...
[1]: https://en.wikichip.org/wiki/mask
[2]: https://en.wikipedia.org/wiki/Electron-beam_lithography