Get Blog posts by categorie

Hello community, I have the latest version of Gohugo and am trying to load a partial and give it a category.
All blog posts that have this category should then be loaded from the blog folder. I’ve tried a few times but I only get errors. Here is my approach. Does anyone have a tip for me? thank you

index.html:

{{ partial "projects_grid" (dict "cat" "dev" )}}

projects_grid.html:
{{ range where (where .Pages “Section” “{{.cat}}” ) “.Params.featured” “!=” true }}


{{ if isset .Params “banner_thumb” }}

{{else if isset .Params “banner”}}

{{ end }}

          <h3>{{ .Title }}</h3>
          {{ .Summary }}

          {{ if .Params.urlExt }}
          <a href="{{ .Params.urlExt | absLangURL }}" class="link--fullscreen" rel="me noopener"
            title="{{- .Params.urlText | markdownify -}}"></a>
          {{ end }}

        </header>
      </article>
      {{ end }}

Call the partial like this:

{{ partial "projects_grid.html" (dict "context" . "taxonomy" "categories" "term" "dev" )}}

layouts/partials/projects_grid.html:

{{/*
  @param pageState .context
    Context of calling page.
  @param string .taxonomy
    Examples: "categories" "tags"
  @param string .term
    Examples: "foo" "Foo Bar"
*/}}
{{ range (index .context.Site.Taxonomies .taxonomy (.term | anchorize)) }}
  {{ .Title }}
{{ end }}
2 Likes

Thank you jmooring :slight_smile:
Have a nice Day !

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