Empty section condition?

I’ve got 2 section folders filled with (only) drafts for future expansion. I list all sections in the navigation and on the front page, can I filter out those “empty” sections somehow?

You can filter them out by setting a custom parameter on the _index.md of these sections.

Something like this would do. (This is in YAML you can figure out the TOML)

exclude: true

And then simply place the following in the relevant template to exclude these sections from your navigation.

{{ $sections := .Site.GetPage "section" .Section }}
{{ range where $sections "Params.exclude" "ne" "true"  }}

I changed the above snippet because what I posted originally is meant for Nested Sections.

1 Like