Filtering .Paginate pages by type not working

I have tried the following, as suggested in the docs, but it continues to show everything else in addition to articles:

{{ $paginator := .Paginate (where .Pages "Type" "articles") }}
{{ range $paginator.Pages -}}

Here is my full term.html template:

{{ define "main" }}
<section class="items-center relative w-full border-b-2">
  <div class="items-center relative w-full border-b-4 mx-auto 2xl:max-w-7xl">
      <div class="flex flex-wrap items-center 2xl:border-x-2 md:divide-x-4">
          <h1 class="md:w-1/3 lg:text-7xl p-10">{{ .Title }}</h1>
      </div>
      <div class="flex flex-col w-full border-t-4 divide-y-4 2xl:border-x-2">
        {{ $paginator := .Paginate (where .Pages "Type" "articles") }}
        {{ range $paginator.Pages -}}
        <div class="w-full flex flex-row flex-wrap items-center">
          <div class="w-full md:w-1/3 aspect-w-16 aspect-h-3">
            {{ $image := .Resources.GetMatch .Params.featured_image -}}
            {{ if $image -}}
                <img src="{{ $image.RelPermalink }}" alt="" class="lazyload blur-up object-cover">
            {{ end -}}
          </div>
          <div class="w-full md:w-2/3 gap-12 p-2 lg:px-6">
              <a class="p-6 w-full" href="{{ .RelPermalink }}"><h2 class="text-4xl">{{ .Params.title }}</h2></a>
          </div>
        </div>
        {{ end }}
      </div>
      <div class="flex flex-wrap  justify-center">
        <div class="md:w-full pr-4 pl-4 lg:w-3/4 pr-4 pl-4">
          {{ template "_internal/pagination.html" . }}    
        </div>
      </div>
  </div>
</section>
{{ end }}

Other posts on this topic have been solved by addressing multiple calls to .Paginator or .Paginate. But as you can see, I’m only calling it once.

Help appreciated!

You are more likely to receive a prompt and accurate response if you post a link to the public repository for your project.

See Requesting Help.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

1 Like

Thanks for the reply. I don’t have a public repo for this project, only a private one. I’ll try to create a dummy repo that reproduces this issue.