How to include exclude section from list by frontmatter parameter

I try to include/exclude sections from a list with a parameter in the frontmatter of _index.md

---
title: foo
exclude: true
---

or

---
title: foo
exclude: false
---

I used this for a while:

{{ $sections := .Site.Sections }}
{{ range where $sections ".Params.exclude" "ne" "true" }}

but only today I realized that it does not what I want.

AFAICS it looks if “exclude” is set at all not if it is not true. Sections with exclude: nil are included, sections with exclude: false are not included.

My guess is that I misunderstand the syntax here. Can anyone help me?

See:

Thanks a lot. I browsed this new feature but did not try it for my usecase. I think that will do the trick.

This topic was automatically closed after 27 hours. New replies are no longer allowed.