pawroman / zola-theme-terminimal

A simple, minimal retro theme for Zola
https://pawroman.github.io/zola-theme-terminimal/
Other
346 stars 76 forks source link

Variable 'config.extra.page_titles' not found in context while rendering 'macros/title.html' #44

Closed djanda97 closed 1 year ago

djanda97 commented 1 year ago

Hello,

I'm interested in using this theme for my blog but I ran into an issue during setup. I successfully added the theme via the git submodule add https://github.com/pawroman/zola-theme-terminimal.git themes/terminimal command and added the theme = "terminimal" value to my config.toml file. The issue that I encountered occurred when trying to run zola serve:

image

For reference, this is the content of the content/_index.md file, showing that the template and page_template values are set to their respective files under the terminimal/templates/ directory:

image

In the themes/terminimal/config.toml file there is a default value for the page_titles variable, however it seems that it is not being recognized. I found a workaround in order for the site to be successfully served by setting page_titles = "combined" under the [extra] section in my config.toml file, but I'm not sure if it is the indented behavior for a user to be required to set this value.

Thanks, David

djanda97 commented 1 year ago

Reading the templates/macros/title.html file, shouldn't the title fallback to {{ main_title }} if a user hasn't set a value for config.extra.page_titles instead of failing to build?

djanda97 commented 1 year ago

Using Zola version 0.17.2

pawroman commented 1 year ago

Hey, yes, absolutely right. This config entry shouldn't be required, and the theme should fallback to {{ main_title }}.

Looks like this is easily fixed by changing the way the title macro accesses this config entry. Something like this seems to do the trick:

-{%- if config.extra.page_titles == "combined" -%}
+{%- if config.extra.page_titles and config.extra.page_titles == "combined" -%}

...

-{%- elif config.extra.page_titles == "page_only" -%}
+{%- elif config.extra.page_titles and config.extra.page_titles == "page_only" -%}

Would you be OK with contributing this fix in a pull request? I'd be happy to merge it.

djanda97 commented 1 year ago

Gladly! I'll open a PR with the suggested fix :smile: