Paginator returns different TotalPages depending on iterattion

This is: /layouts/index.html:

{{ define "main" }}
    {{.Content}}
    {{ $paginator := .Paginate (where .Site.RegularPages "Type" "post") }}
    We have {{ $paginator.TotalPages }} pages.
    <br/>
    {{ range $paginator.Pages }}
        <span class="article-title">{{ .Page.Title -}}</span>
        <span class="article-topics">{{ partial "taglist.html" . -}}</span>
        <div class="article-meta">
            by {{ .Params.author }} ({{ .Page.Date }})
        </div>
        <p>
        <span class="article">{{ .Page.Summary }}</article>
        </p>
        <a href="{{ .Page.Permalink }}">Read more</a>
        <hr/>
    {{ end }}

    Page {{ $paginator.PageNumber }} of {{ $paginator.TotalPages }} pages.

    {{ if ne $paginator.PageNumber $paginator.First.PageNumber }}
    [<a href="{{ $paginator.First.URL }}">First</a>]
    {{ end }}

    {{ if $paginator.HasPrev }}
    [<a href="{{ $paginator.Prev.URL }}">Previous</a>]
    {{ end }}

    {{ if $paginator.HasNext }}
    [<a href="{{ $paginator.Next.URL }}">Next</a>]
    {{ end }}

    {{ if ne $paginator.PageNumber $paginator.Last.PageNumber }}
    [<a href="{{ $paginator.Last.URL }}">Last</a>]
    {{ end }}

{{ end }}

There are 113 pages with type: “post”, and 10 pages with type: “base”. Front matter has paginate = 5.

On first iteration, TotalPages is 23. But as soon as you move to any of the other pages, TotalPages is 25. AND, the displayed pages include the “base” pages.

Any help would be appreciated.

I am unable to reproduce the behavior you describe.

Please share a link to the public repository for your project.

See https://discourse.gohugo.io/t/requesting-help/9132.

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.

No need. The solution was to clean out the public/ directory from a prior run, and reissue hugo. But for what it’s worth, Hugo really should do this itself.