Hugo

Given an array of pages, get an array of some parameter

Hello all,

I’ve noticed what seems to be a bit of an inconsistency in versions of hugo when trying to iterate pages vs sections in a template. Basically I have these two variables:

{{ $pages := where .Pages ".Params.hide_from_menu" "!=" true}}
{{ $sections := where .Sections ".Params.hide_from_menu" "!=" true}}

I don’t know for sure yet, but it seems some versions of Hugo include the elements of $sections in $pages, and some don’t.

Just to be sure, I’d like to create an array which is the elements of $pages that are not in $sections

I’ve tried the following but comes up empty:
{{ where $pages "." "not in" $sections }}

I’m guessing I could use something like this:
{{ where $pages ".UniqueID" "not in" $sections_ids }}

But I can’t figure out how to create an array of sections ids given an array of sections.

I found a solution:
$pages | complement $sections