A simple task, or so I thought: in a Jinja template keep track of the number of items in a loop. And then use that count afterwards.
Disclaimer: the number of items is not equal the number of times the loop runs, so I can’t use the loop variables.
Turns out that Jinja has other opinions, and variables inside a loop are all local. When a variable is changed inside the loop, the scope of the variable stays local, and once the loop ends the original value of the variable is restored. That’s even true for variables which are created outside the loop.
Hugo is a static templating system. It is (mainly) used to deploy websites/blogs which don’t have and need dynamic content. The content of all pages is pre-generated, and the webserver delivers files from disk (or rather from cache, once files are loaded into memory). This approach allows for extremely fast websites, as no dynamic content is generated on every request.
While I know Hugo from work, I haven’t really used it for private projects - until recently. I have started a new project where I present interviews with people behind the PostgreSQL Project - and this is perfect for a static website. Interviews don’t change, once published.