The Zola docs has an example like this, which is a very common pattern:
<head>
<title>{% block title %}{% endblock title %} – {{ config.title }}</title>
</head>
Now, lets say I wanna add a few more call-sites to the value being resolved as title here, such as:
<meta name="twitter:title" content="..." />
and
<meta property="og:title" content="..." />
As far as I understand from https://tera.netlify.app/docs/#inheritance, it’s not possible to use blocks in resolution of variables, so there’s no way to use {% set ... %}
to have a local title
variable to use in all those three cases of the title value needed.
Of course, another option is to copy-paste the same logic into all three places. But that’s harder to maintain in the long run.
Is anyone aware of any solution for this, to be able to prevent duplication of the same composition, while using inheritance?
Fwiw, at the moment, I’m using local variables to calculate the title
value, with {% if ... %}
conditions for various section
and page
values. Of course, this is doable, but again non-ideal, since it’s forcing me to put section-specific logic into my base template. Hence, I’m looking for a solution better than this.