Having a common property that can be used in pages and sections

Zola has a concept of pages and sections which have similarities. According to the docs, a lot of the variables of sections and pages are common among the two:


The issue though is that when trying to access these variables in the templates, I have to reference the “section” object in sections and the “page” object in pages. This is inconvenient for me, because I have some HTML templates that have shared use across both sections and pages.

Here is a little hack I did to be able to use the variables in a common way by simply copying “section” to “page” in a template if it’s being rendered as a page in my open source blog:

Though to be fair, the reason I needed to do that in the first place was that I couldn’t use the home page properly like a page like in this discussion:


Anyway, I thought that still, it could possibly be useful if there was a shared object that could be used in both sections and pages that had the common properties. I’m a bit new to Rust, but thanks to some basic knowledge and a lot of IDE help, I was able to write up a Proof-of-Concept commit:

What are your thoughts?

It’s a semi-common issue but I think it’s better done by using the same variable name for both page and section rather than making code changes.