This is almost certainly beyond the scope of what zola aims to be, but is something that I’ve been thinking about for a while.
Many websites I’ve worked on are about 99% static, with a small amount of basic dynamic functionality; such as a search form, or filters for posts. To add this to a purely static site either requires 3rd party services, or client-side search which can generate large index files. The logic required to do search and filtering, however, is probably well within the capabilities of zola’s template engine.
In such circumstances, it would be amazing if a static site generator supported a command to render a single page on demand, something perhaps like this zola single <url>
. If any query strings were passed through as variables to the template, a server could check whether a request had a query string and, if so, instead pass the request as an argument to the single function.
Which could then be processed by a template with similar logic to this (psuedocode):
{% if request.date_from %}
{% set posts = posts | filter(attribute="date", value=value < date_from)%}
{% endif %}
{% for post in posts %}
{{post.name}}
{% endfor %}
So if the request was for https://example.com/posts
the server would serve the prerendered file, buit if the request was for https://example.com/posts?date_from=2022-01-11
it would pass this to the zola single
command and serve the output.
As I say, this is probably well beyond zola’s intended scope and would probably be fairly non-trivial to implement. However, functionality like this could be a nice way of bridging the gap between fully static sites, and those with a small amount of dynamic functionality.
I believe 11ty has a concept similar to this with it’s serverless features, but the execution looks far more complex.