[Solved] How to filter posts with Taxonomy

Hi I am tryin to get things done in Hugo. At the moment i have a problem.
I have a frontmatter like

categories = ["Sport"]


1. I want to filter articles with that Taxonomy.

{{ range where .Site.Pages "Params.categories" "Sport" }}
   {{ .Title }}
{{ end }}

2. I want to display Title / Image / Bodytext as seperate fields.
not the whole article like {{ .Content }}

I hope its clear what i mean.

Thx for help

See https://gohugo.io/taxonomies/displaying/. Look at section 2.

Thx for your kind reply.

I have looked at that section and tried it a couple of days ago. Nothing happens.

{{ range .Site.Taxonomies.category.sport }}
        {{ .Content }}
{{ end }}

I get no result. And for me its very unclear how to iterate over Taxonomies.

I am working on a special Layout where Blocks with Posts are shown depending on Tags or Categories.

In that example above i want to filter out all Posts with Frontmatter “categories = [“Sport”]” and display in an extra Block.

Hope that makes sense.

Hi All,
I figured it out.

  {{ range first 1 .Site.Taxonomies.categories.sport }}

      <h2><a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a></h2>
        {{ .Page.Summary }}

  {{ end }}

Maybe this is something for the documentation?

Thx for your support - Great community

1 Like

Your answer helped solved my problem as well :slight_smile: