Using `where` filtered on `post` value of menu items returns empty collection


I’m abusing the pre and post values of menu items to create “sections” in a drop down menu. I’m trying to implement this for the Hugo universal theme based on the upstream boostrap version:

See the menu items “Features” or “Portfolio”.
I’m setting the post value to a the column number where the menu items need to end up in, e.g.

    name       = "Portfolio"
    identifier = "section.portfolio"
    url        = ""
    weight     = 1
    parent     = "menu.portfolio"
    post       = 1

    name       = "About"
    identifier = "section.about"
    url        = ""
    weight     = 2
    parent     = "menu.portfolio"
    post       = 2

In my template, I want to filter the children of the top level menu item based on this post value:

{{ range where .Children "Post" "==" "1" }}
{{ end }}

But my collection always returns empty. I tried the following variants, but to no avail:

{{ range where .Children "Post" "1" }}
{{ range where .Children "Post" "=" "1" }}
{{ range where .Children "Post" "==" "1" }}
{{ range where .Children "Post" "eq" "1" }}

What am I doing wrong?


Try printing post as a string: {{ $post := printf "%s" .Post }}

@budparr, when debugging, it prints the string 1 and 2. But the Menus documentation reads that Pre and Post are of type template.HTML.

Can you tell me what I have to write in the range where section to get the matching children?


Here’s how I used Post in the Hugo docs to put breaks between section:

You could also just create the menus as separate (e.g. [[menu.main1]] [[menu.main2]]) and range through all of them where you need them together. Seems like a more straigtforward way of handling it.