3 minutes reading time
Last year, I decided to migrate my Jekyll website to Zola. The old project was based on the Halve theme and was quite outdated, so I thought it would be a good exercise refreshing it. While porting the old site wasn't hard, making Halve-Z a flexible theme was a slightly different challenge. I had to refactor and combine page layouts to allow proper template overrides, implement security policy mechanics, and then refactor again to get all the new elements and improvements to work seamlessly. Oh, and, of course, glitched bits!
Besides switching SSGs, the host side also received an upgrade. I finally dropped GitHub Pages and moved to Netlify. Now I can actually control HTTP headers (yea!) and branch/pull request deploys are baked in!
netlify.toml
:
[]
= "public"
= "zola build"
[]
= "0.18.0"
[]
= "zola build --base-url $DEPLOY_PRIME_URL"
[]
= "zola build --base-url $DEPLOY_PRIME_URL"
[[]]
= "/*"
[]
= "*"
= "DENY"
= "nosniff"
= "1; mode=block"
= "public, max-age=604800, must-revalidate"
= "frame-ancestors 'none';"
= "strict-origin-when-cross-origin"
= "max-age=63072000; includeSubdomains"
Just push commits, then preview changes via prefix. Sweet!
Themes in Zola can be handled as Git submodules, and GitHub's Dependabot can automatically pull updates for users' projects.
.github/dependabot.yml
:
version: 2
updates:
- package-ecosystem: "gitsubmodule"
directory: "/"
This configuration will raise pull requests when updates are available.
And to install this theme as a submodule:
The index/homepage now has a scrollable info block, so it could fit more text without breaking the layout, and the main logo is now optional. I also added a footer and some glitching effects to make things more gripping, e.g., when the logo is off. These elements are optional and controlled via config.toml
.
Besides basic functionality like tags and categories, Halve-Z also supports automatic color profiles, extended HTML formatting, a commenting system (Giscus), and media and data shortcodes.
The original layout for the projects page was just a container with an image and a link. But I wanted to make it more informative, so I ended up implementing simple project cards with basic details and a language indicator.
It took me a while to figure out how to handle CSP at the level I needed. Of course, my current implementation might be overkill, but https://*
wildcard for img-src
directive feels too reckless, so the theme's front matter has a dedicated csp_img
option.
Since I decided to support external media, I had to wrap inlined CSS for images into custom macros to be able to calculate hashes for the style-src
directive.
It's a bit awkward, but it works. And I got A+ grades on Mozilla's Observatory.
Zola is using a different template engine, so I had to adjust the original approach to be able to fully utilize Tera's blocks. Partial template overrides are very handy!
{% block body %} {% endblock body %}
{% if current_path | default(value="none") != "/" %} {% endif %}
{% block left %}
{%- block page_title %}{% if page.title %}{{ page.title }}{% elif section.title %}{{ section.title }}{% elif term.name %}{{ '#' ~ term.name }}{% else %}{% endif %}{% endblock page_title %}
{% endblock left %}
In this example, users can override the body
block and assign different IDs to a tag, or set a custom title with the page_title
block.
Somehow I managed to reach the target functionality without completely messing up the CSS. Or I just like to think that way because I really want to rewrite the whole ruleset from the ground up. For now, I will just enjoy the result and wait for Tera v2.