profile picture
HomeNotesLinks

Stop doing templating languages

Tue, Sep 2 2025

I think HTML templating languages like jinja2, handlebars and go templates are the wrong solution. If what you are doing makes you reach for these tools, consider using a general programming language instead. HTML templating languages limit you to the subset of general programming patterns the language author has chosen to implement.

You don't have to do a lot of templating before thinking to yourself:

It would be nice to extract this section and use it in all these other places without repeating myself too much.

—A developer creating a site using an HTML templating language, probably

I hope the templating language you picked supports arbitrary user-defined snippets with the capacity to pass arguments. If you were using a normal language, you would use a regular function and move on.

This is mostly a public reminder to myself because I foolishly once thought writing a templating language was a good idea. I learned a lot in the process though, so I have no regrets. Once I got the basics working, I quickly realized that to make it useful, you basically have to implement variables, functions, arguments, loops etc... And at that point, why not just use an existing language?

Built from git commit babbe3b