Posts listing and pagination doesn't work when files moved

Below listing and pagination codes works when my post-title.md posts are under /content/post-title.md.
Nothing is displayed on homepage when I move posts into subdirectory (posts section): /content/posts/post-title.md.
How to modify below code examples?

It doesn’t work on homepage. It works on taxonomy pages and /posts/

<section>
    <div class="latest-posts-section">
      <div class="loop-wrap">
        {{ $paginator := .Paginate .RegularPages }} # I think this should be changed
        {{ if $paginator }}
        {{- range $paginator.Pages -}}
        {{ partial "post-card.html" . }}
        {{ end }}
      </div>
      <div class="break"></div>
      <div class="pagination">
        <a href="{{ .RelPermalink }}page/2/" aria-label="Load more" style="display: none;"></a>
        <button class="button-primary">Load more</button>
      </div>
      {{ end }}
    </div>
</section>

It doesn’t work either

$paginator := .Paginate (where .Site.RegularPages "Type" "posts") }}

head.html got “{{ $paginator := .Paginate .RegularPages }}” which cause the issue.
changed to $paginator := .Paginate (where .Site.RegularPages “Type” “posts”) }}
now it works

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.

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