I am using the IN
function of Hugo that can be used as in SET ITEM
as defined at Hugo Documentation for IN
I am trying to filter out posts of a particular category by the below code
{{ range where .Site.Pages "Section" "products"}}
{{ if in .Params.categories "New Arrival" }}
<li>{{ .Title }}</li>
{{end}}
{{end}}
the above code works completely fine.
But if I use a variable instead of a string for the ITEM
. It always returns False
.
{{ $display_product_cat := "New Arrival" }}
{{ range where .Site.Pages "Section" "products"}}
{{ if in .Params.categories $display_product_cat }}
<li>{{ .Title }}</li>
{{end}}
{{end}}
The above code does not work as expected.
Wondering if I am missing something here. Appreciate your time and help.