Mmm, I don't think that's the way Randall (creator of xkcd) post his comics.
It seems that you believe that this is his way because you learned that the
2148 of that URL
https://xkcd.com/2148/ is a folder on the server, which has inside an
While this CAN be one way to do that, there are plenty of ways, for example using some framework based on the coding language of your choice.
In simple words: normally there are a piece of software that runs on the server, which get your request (ie:
https://xkcd.com/2148/), elaborate it gluing together the "main template" (header, footer, layout) and the comic requested (
If you want to learn how to do it, I'll suggest you to look over some simple php framework, like laravel, with some tutorial.
It may be confusing at the beginning, but it's a good start if you want to use PHP.
Alternatively, in this answer are present some very good advice to start learning web development: https://softwareengineering.stackexchange.com/a/15329/336186