Need help

I have two main content types on my blog. There are posts and river. Posts are long format while river is just random things I post more regularly. I want the homepage to show only the posts. I cannot get this to work with pagination. I either get empty slots on the page for filtered river items or all items show up. The code below is the partial I use for the main homepage. It currently pulls all items regardless of type although I thought it should filter the posts. Any help would be appreciated. I’m at a loss.

{{ define "main" }}

  {{ $pages := where site.RegularPages "Type" "posts" }}

  {{ range (.Paginate $pages).Pages }}
      <article class="post-list">
          		{{ .Title }}
      	<div class="content">
        	{{ .Content }}
      	{{ partial "articleInfoFull.html" . }}
  {{ end }}
  {{ partial "pagination.html" . }}

{{ end }}

Can you share the repository for your project? There’s nothing wrong with the code you have posted, so we’ll need to look a little deeper. Thanks.

I have pushed all the recent changes.

This is the problem:

You are calling .Paginator/.Paginate twice on the same page. See:

For a given Page , it’s one of the options above. The .Paginator is static and cannot change once created.

If you call .Paginator or .Paginate multiple times on the same page, you should ensure all the calls are identical. Once either .Paginator or .Paginate is called while generating a page, its result is cached, and any subsequent similar call will reuse the cached result. This means that any such calls which do not match the first one will not behave as written.

You are correct. That solved the problem. I don’t know if it was technical debt or technical illiteracy :joy:. Thank you for your help.

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