I recently proposed that it should be possible to break up the markdown of an .md
file in order to address sections of it seperately in the Tera templates. This is working well in my fork, and allowed me to simplify and clean up some of my pages and templates. However, it somehow still felt like I was working against Zola, so I figured I’d write a toy SSG to try to identify where that was coming from.
I think I have now identified what’s going on. Essentially, Zola is a very good blog generator, but if your website is not sufficiently like a blog, you’re going to have to do some ugly things.
The main difference between my toy SSG and Zola is that the content hierarchy represents the layout of the website rather than the structure of the data. The placeholders for HTML pages are .page
files, which are pure TOML files. There is no concept of a section – if you want to have a page representing a section, just write a page representing a section. index.page
does have one magical property which is that the weight defaults to None
, meaning that it won’t, by default, appear in a sibling list, so this is probably a good place for it.
Each .page
file has an optional [content]
section listing files to load and an optional [data]
section for ad hoc data. The only top level items are template
to link the template to present the data to, and weight
to control the ordering of siblings. There is no markdown involved. In fact markdown is explicitly out of scope in general. If you want to write markdown, rst, asciidoc or whatever, go right ahead, then convert it to HTML and reference the HTML file in the [content]
section to present it to the templates.
Everything in the content hierarchy gets copied across verbatim to the public hierarchy other than the .page
files, which get replaced with the created .html
files, and any directories containing a file named .ignore
. If you want SASS, SCSS or whatever, just write your code, stick an .ignore
file in the directory containing that code and pre-process it to a CSS directory or whatever to be copied across.
Files listed under [content]
may be HTML or TOML, and the HTML may be sharded. The templates have access to the data from all pages, the weighted relationship between siblings and the sub-directories of the directory they are in. This gives a huge amount of flexibility in structuring the data and text content of your website.
Since the content hierarchy is exactly the same as the layout of the site, all internal links can be handled as relative links. A variable called root
is provided to the templates to facilitate this. {{root}}/css/styles.css
, for example, refers to /content/css/styles.css
from any .page
file. This means that the whole public hierarchy can be dropped anywhere, and it just works. You can even test in the browser with file://
urls. This has allowed me to go back to my preferred workflow of uploading to a staging domain and then synchronising that with a production domain once the website has been thoroughly tested.
All of which is to say that in around 300 lines of Python, my toy SSG covers a great many of the feature requests in this forum. I have now thoroughly scratched my own particular itch, and will be using it going forward. I think, however, that there would be value in allowing Zola to operate in the same way for those that are not building blog-like websites. Obviously this way of operating is completely opposed to the normal way Zola operates, so it would have to be a separate mode that you could select in the config file.
I’m honestly not at all sure this is a good idea, but I thought I would put it out there for discussion.