Z12.2: can't access an `[extra]` property on section?

I have the following snippet generating a list of active projects:

{% for category_subsection in category.subsections %}
        
  {% set project = get_section(path=category_subsection) %}
        
  {% if not project.extra.active %} {% continue %} {% endif %}
                
  <li>
    <a href="{{ project.path }}">{{ project.extra.logline }}</a>
  </li>
            
{% endfor %}

As you can see, it takes a subsection, discards it if it isn’t active, and prints a list item with project information. Or so I thought. It doesn’t discard the project if it’s inactive: it discards the project if it doesn’t have project.extra.active property, which is not the kind of filtering I need.

So I went on to rectify it today:

  {% if project.extra.active == false %} {% continue %} {% endif %}

Which landed me with an interesting error:

Failed to build the site
Error: Failed to render section '<directory>\content\_index.md'
Reason: Failed to render 'index.html'
Reason: Variable `project.extra.active` not found in context while rendering 'includes/frontpage/current_projects.html'  

The reason it’s interesting is because I’ve manually written an active = true/false property under the [extra] TOML heading in every single project I have on the site.

The other reason it’s interesting is because, with the previous “wrong” version of the template, I end up with a list of projects rendered exactly as I wanted it except for status filtering. That’s not what’s supposed to happen, is it? It’s supposed to skip all projects that don’t have .extra.active defined, meaning Zola has to be able to access it in some capacity. I’d think so, given that {% if project.extra.active %} {% endif %} (no negation) causes the exact same issue as not having the conditional at all…

…which is that Zola can’t seem to access the project.extra.<name> property (again, perfectly in-place and written and a string). The project.extra section can be rendered in the template and returns exactly what you’d expect: the [extra] section of the project’s TOML definition, exactly as I’d written it, for every project.

TL;DR: Even though the properties are present and can be rendered in JSON on the page, Zola throws trying to access them.

That’s odd, I just tried the following snippet on my site and it worked fine?

    {% set project = get_section(path="blog/_index.md") %}
    {{ project.extra.active }}

after having set

[extra]
active = true

in my blog section front-matter.
Can you make a small reproduction I can run?

I’ve been trying to figure out how to accomplish that, and I admit: I’m confused as to how to pull that off.

Would a full copy of the raw site suffice, instead? There’s no private content, and the site’s gonna be published soon anyway.

I ask because I’ve stumbled upon the second time Zola fails to read a section property, and this time it’s more important 'cause I’m not failing to display content I should display.

Yep that would be fine, you can send in PM as well if you don’t want to post it publicly yet

This can now be closed: @keats helped me identify the issues with templating on my end, and the build process now works without a hitch.

1 Like