HUGO: error calling where: can't evaluate the array by no match argument or more than or equal to two arguments
Asked Answered
P

1

1

I am trying to create a ul list of the sections of my hugo site and their child pages that have a specific param.

I basically want a multi-level ul menu at the side like so:

  • Intro
    • Page 1
    • Page 2
  • Section
    • page 3
    • page 4

Here is the Hugo Code I have so far:

<ul class="section-one-and-two-pages">
{{ range .Site.Pages }}
    {{ range where ( where .Section  "intro" ) or ".Params.type" "==" "article" }}
   <li>{{.Permalink}}{{.Title}}</li>
    {{end}}
{{ end }}
</ul>

At the top of my pages (.md) I am adding:

type: = "article"

However I cannot seem to get this to work. I keep getting the Error:

Error calling where: can't evaluate the array by no match argument or more than or equal to two arguments

When compiling. Any ideas?

Prothallus answered 20/10, 2017 at 11:49 Comment(4)
Is type: = "article" yaml or toml? To me it looks like a bit of both.Laevogyrate
Not sure, I just coped the title: "Test Post" that was generated by hugoProthallus
Do you have any ideas on a solution to my problem? I'm literally pulling my hair our....Prothallus
Could you post the whole of your .md file metadata, including the separators? I have a feeling that is where at least part of your problems is. Also, you should only need one "range" statement, but I'll need to actually test that before I can give you a good answer.Laevogyrate
S
0

Just for people running into this old question: the position of the 'or' is wrong. The right syntax is or condition1 condition2, see https://gohugo.io/functions/go-template/or/.

Read more about or and where at https://discourse.gohugo.io/t/using-or-with-where/10408.

Scrouge answered 7/11, 2023 at 8:34 Comment(1)
please expand. meta.stackexchange.com/a/8259/997587. at least show the corrected version. ideally, explain why it's wrong.Denude

© 2022 - 2024 — McMap. All rights reserved.