Universal Page layout for all pages in a Zola site

I’m using Zola to make a static website. All of the pages follow pretty much the exact same HTML layout no matter what section, so that means I’d only need 1 layout template.

However, I can’t seem to be able to do that since metadata is stored in different variables: if I want the title of the page, I have to use either {{ section.title }} or {{ page.title }} depending on whether I’m working with a section or a page.

This would mean I’d need to make two templates with the same HTML structure but with different variables, and I just really don’t want to do that because it would be repetition.

So, is it possible to have one, universal HTML layout for all pages? Does this conflict with how Zola is supposed to work somehow? I can’t tell; I’m coming from a Cobalt background, and Cobalt is an SSG that allows this stuff easily since there’s no distinction between section.foo and page.foo — it’s all page.foo.

1 Like

So there is Section vs Page discussing that.
It is kind of a toss between whether people like the distinction or not (I like it myself but I understand why some don’t).
In the meantime you can do something like {% set content = section or page %} at the top and you can refer to content for the rest of the template.

1 Like

This is my code, and it’s not working. I have {% set any = section or page %} at the top and I have referred to any, but it’s not working.

It looks like something like:

    {% if page %}
    {% set any = page %}
    {% endif %}
    {% if section %}
    {% set any = section %}
    {% endif %}

works. Not sure why or doesn’t work though

1 Like

Thanks you SO MUCH for the help! You rock!

This definitely looks like a hacky thing and I think that something like any should be implemented, but as long as it ain’t broke, I won’t fix it. :)

P.S. I’m new to Discourse, how do you stop the message window from trying to convert emoticons into emoji?