Filter pages by presence of a parameter, independently from its value

I’m trying to single out a type of page (i.e. release type) from a certain section. Here is what I have so far:

{{ $releases := (where (where .Site.RegularPages "Section" "updates" ) isset .Params "release") }}

Now, I thought the outer where would work just like:

(where (where .Site.RegularPages "Section" "updates" ) ".Params.Featured" true)

But that’s not the case. The build fails, exactly at the way I’m using isset with this error:

<isset>: wrong number of args for isset: want 2 got 0

I’d really like to understand what I’m doing wrong here.

You must call the function as described in the documentation:
https://gohugo.io/functions/collections/where/

  • Your args are in the wrong sequence
  • “isset” is not one of the allowed operators

Thanks! Here’s what I came up with:

{{ $releases := (where (where .Site.RegularPages "Section" "updates" ) "Params.release" "ne" nil) }}
{{ with index $releases 0 }}
   {{ .Title }}
{{ end }}

And it works. Cheers.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.