Where(function) doesn't work with multiple params

{{ range where .Pages “Params.tags” “Linux”}}
This is the code i’ve been using and it only works if example.md tags look like:

Title: “Something”
tags: “Linux”

As soon as i switch tags to:

Title: “Something”
tags: =[“Linux”, “Windows”]

It doesn’t display the pages with Linux anymore since there’s another tag,it seemed to work when used in hugo docs,i’ve tried to change the code to .Pages “Params.tag” and change tags in the md to:

Title: “Something”
tag: =[“Linux”, “Windows”]

So i im sure it’s not a problem with plurals.

There is a function called in.

Understand this:

WHERE tags IS linux works on tags: linux. tags=["linux", "somethingelse"] is something else, along the lines of not a string but an array with strings :wink: So you have to check if your test-string is in the array of tags.

Something along the lines

{{ range where .Pages "Params.tags" in "Linux" }}

Not tested. But the first sample in the linked doc looks a lot like what you want.

i’ve tried {{ range where .Pages “Params.platforms” “in” “Windows”}}
since in without “” displays an error.It doesn’t fix the issue even though i looked it up and it should,i’m not sure where i messed up

Use intersect instead of in.

1 Like

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