[SOLVED] Unpublished nested sections

In my section template, I’m listing pages like this:

{{ range ($.Site.GetPage "section" "subsection").Sections }}
    ...
{{ end }}

But in some subsections, my _index.md is unpublished (draft: true)

How can I filter unpublished sections when using .Sections ?

Draft is only built with the draft flag, so building without that flag should filter those … but I expect that isn’t what you’re asking.

You would have to use where I guess.

Ok, I finally understood what was going on. I was trying this:

{{ range where .Sections ".Params.draft" "!=" true }}
    ...
{{ end }}

If you do that, it will list all the pages that have an _index.md file with the param draft: true. But since hugo is not building the pages that are in draft mode, it creates automatic pages for those sections. Those pages don’t have a draft parameter. So what you really have to do is:

{{ range where .Sections ".Params.draft" "!=" nil }}
    ...
{{ end }}

So it lists all the pages that have a draft parameter defined.

I guess you could also use a where to check if they’re really published. But in my case, it wasn’t necessary.