Limit taxonomy type

Hi all,
I’m not sure how to do this so wanted to ask here. How can I limit the number of posts for a taxonomy term?
I am using the latest version of HUGO.

My code snippet:

{{ range }}
  {{ partial "baz" . }}
{{ end }}

I tried {{ range first 5 (where }} but then gave me an error saying it expected two but only got one.

Thanks in advance.

I haven’t verified but try using parentheses to make it clear as to which arguments go to range and which go to first: {{ range (first 5 (where }}

Update Sorry for the bad advice above; @jmooring has fixed that.

Also, it’s more canonical to use site. instead of .Site.. That way you never end with with an issue of attempting to get the Site object from a wrong scope.

1 Like

There’s no need to use a where clause here.

{{ range first 5 }}

Thank you so much! This worked for me. If I replace first with shuffle it doesn’t work, how could I shuffle 5 posts from the taxonomy.

{{ range shuffle 5 }}

This did not work (

{{ range (first 5 | shuffle) }}
1 Like

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