I’m trying to set up Zola to enable me to repeatedly include little bits of HTML (e.g. <span class="blue-tag">blue</span>). I thought maybe I could define these as variables and then use {{ blue_tag | safe }} in my Markdown, but this directive isn’t evaluated.
Is the reason for this just that directives like this are only usable in templates? Is there any way to do this sort of simple macro expansion from Zola Markdown sources?
It is not in the HTML spec, so it will fail HTML validators but it works in all browsers. And you can use it everywhere, not only Zola.
Define some CSS the way you want (templates, css files, even inline in the MD)
<style>blue {color:blue;}</style>
And then you can use it <blue>as simply as that!</blue>, this is even more readable and less verbose than shortcodes.
Important points:
It works with search engines: Google for instance interprets them as span elements.
It does not impair your SEO
Actually, you can make them valid by just adding an hyphen in the name: e.g . Cf Custom Elements spec
If needed, You can ensure they are accessible by explicitely adding ARIA properties (no need to add these by hand, some JS code can do it)