Can you check how many elements a param has?

When ranging over a page param, I want to handle it differently based on if there is only one element.

Example md:

- colour: green
  size: medium
- colour: blue
  size: large

- color: green
  size: medium

Example pseudocode:

{{ range .examples }}
{{ if .examples.count > 1 }}
(handle param e.g. print size only if there are two elements)
{{ else }}
(handle param differently, e.g. only print colour)
{{ end }}

Is this possible? If not, any suggestions on how to implement this behaviour?

Thank you!

You can use the len function: len | Hugo

Will look at this, thank you!

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