Pagination doesn't work after Hugo update after a few months

Hugo Static Site Generator v0.58.3/extended darwin/amd64 BuildDate: unknown

Before update I had:

Now I have:


^ this Posts is a link to http://localhost:1313/posts/

{{ $paginator := .Paginate (where .Pages "Section" "posts") }}
or
{{ $paginator := .Paginate (where .Pages "Type" "posts") }}

list the same what is above.

Considering documentation it should be still valid:

I have no idea what is happening here. Debugging hugo template is a nightmare :frowning:

{{ $paginator := .Paginate (where .Pages "Section" "posts") }}


<pre>{{ $paginator | jsonify }}</pre>
<br />---<br />
{{ printf "%#v" $paginator }}

{{/*  posts summaries */}}
{{ range $post := $paginator.Pages }}
<div class="row no-gutters post-summary" onclick="location.href='{{ $post.RelPermalink }}';">
    <div class="{{ if $post.Resources.Match "thumbnail" }}col-md-8{{ end }} post-content">
        <a href="{{ $post.RelPermalink }}"><h1>{{ $post.Title }}</h1></a>
        <div class="post-meta">{{ $post.Date.Format "2006-01-02" }}
            {{ if lt $post.Date $post.Lastmod }}
                <span>(updated: {{ $post.Lastmod.Format "2006-01-02" }})</span><br />
            {{ end }}
            {{ partial "taxonomy-terms.html" (dict "root" . "taxonomy" "tags")}}
        </div>
        <p class="summary"><a href="{{ $post.RelPermalink }}">{{ .Summary }}</a></p>
    </div>
    {{ with index (.Resources.Match "thumbnail") 0 }}
        <div class="col-md-4 post-image">
            <a href="{{ $post.RelPermalink }}">
                <img class="img-fluid" src="{{ .RelPermalink }}" alt="{{ .Title }}">
            </a>
        </div>
    {{ end }}
</div>
{{ end }}

{{/*  pagination  */}}
{{ if gt $paginator.TotalPages 1 }}
<nav>
    <ul class="pagination justify-content-center" style="flex-wrap: wrap">
        <li class="page-item{{ if not $paginator.HasPrev }} disabled {{ end }}">
            <a class="page-link" href="{{ if $paginator.HasPrev }}{{ $paginator.Prev.URL }}{{ end }}">
                <span aria-hidden="true">&laquo;</span>
            </a>
        </li>
        {{ range .Paginator.Pagers }}
        <li class="page-item{{ if eq . $paginator }} active{{ end }}"><a class="page-link" href="{{ .URL }}">{{ .PageNumber }}</a></li>
        {{ end }}
        <li class="page-item{{ if not $paginator.HasNext }} disabled {{ end }}">
            <a class="page-link" href="{{ if $paginator.HasNext }}{{ $paginator.Next.URL }}{{ end }}">
                <span aria-hidden="true">&raquo;</span>
            </a>
        </li>
    </ul>
</nav>
{{ end }}

Instead of

.Pages

Use

site.RegularPages
1 Like

Thank you. Can you give me an advice how could I solve it myself? Any debugging tricks? Should I know it from documentation or changelog?

PS Does it mean pagination documentation is not up to date?

This GitHub issue will give you some history https://github.com/gohugoio/hugoThemes/issues/682

1 Like

Thank you for your answer, that saved me some more hours of โ€œdebuggingโ€

1 Like