List sections by section name and access param in sub pages

Hi There,

I have recently returned to an old site I tried hugo with ages ago when I was trying it out. On a _default/list.html page I had this code:

{{range .Site.Sections.ByTitle }}
    {{ partial "section-lists.html" . }}
{{ end }}

And in the section-lists.html I had:

   <li><a href="/guides/{{ lower .Params.ProductName }}-{{  lower .Params.ProductCode }}">{{ lower .Params.ProductName }}</a></li>

It used to output a list of all my content.

However this has stopped working now and my needs have also increased.

What I am looking to do is the same as above with a little difference. Let me explain:

I have this structure

– home-products
– - -
– - -
– - -
– garden-products
– - -
– - -
– - -

each of the file I have a param set in the font matter:

productName: "Soap"
productCode: "32145124"

On different parts of my site I need to output a list of products, in alphabetical order based on what is in the section.

I have tried:

{{ range where .Site.Sections "home-products" }}
     {{ partial "product-lists.html" . }}
{{ end }}

and in the product-lists.html I have:

<a href="/home-products/{{ lower .Params.ProductName }}-{{  lower .Params.ProductCode }}"> . 
    {{ .Params.ProductName }}

However I get the error:

can’t evaluate the array by no match argument or more than or equal to two arguments

Can anyone help?

Try this:

{{ range where .Pages "Type" "home-products" }}

First, you have productName and productCode in content files while you use .Params.ProductName and .Params.ProductCode (1st letter capitalized) in template code.
Second, try to change it like this

{{ range (where .Site.RegularPages "Section" "eq" "home-products") }}
     {{ partial "product-lists.html" . }}
{{ end }}

This worked amazingly. Thank you.

huh? I dont know what this means