New hugo server error <.Paginator.Pages> in new 0.79.0

Hi,

Hugo server -D was working perfectly until this afternoon. No change has been made to the partials or content. Now I am receiving this error when try to build the site:

Start building sites …
Built in 523 ms
Error: Error building site: failed to render pages: render of “section” failed: “/home/elvis/Web/SF/themes/Belli/layouts/_default/sections.html:15:23”: execute of template failed: template: _default/sections.html:15:23: executing “main” at <.Paginator.Pages>: error calling Pages: runtime error: invalid memory address or nil pointer dereference

This is the line with the error:

{{ range .Paginator.Pages.ByWeight | first 5}}

Now the hugo version is:

Hugo Static Site Generator v0.79.0/extended linux/amd64 BuildDate: 2020-12-17T00:26:40Z

This is the partial template that generate a list of sub sections and post on those sub sections, but now is giving an error on <.Paginator.Pages>

{{ define "main" }}
<section class="section">
{{ $currentSection := .CurrentSection }}
{{ range $section, $taxonomy := .Site.Sections }}
{{if eq $taxonomy.Title $currentSection.Title}}
<h1 class="title is-3 has-text-centered">{{ $taxonomy.Title | title }}</h1>
{{.Content}}
<ul>
{{ range $taxonomy.Pages }}
<hr>
<li class="title is-4"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ .Content }}
<br>
{{if eq (len .Paginator.Pages) 0}}<p class="has-tex-centered has-text-info">Disculpa. Aún estamos desarrollando contenido para esta sección.</p>{{end}}
{{ range .Paginator.Pages.ByWeight | first 5}} **Here is the error!!!**
<article class="media">
<div class="media-content">
<a href="{{ .RelPermalink }}">
<h1 class="title is-6">{{ .Title | title }}</h1>
</a><div class="level is-mobile details">
    <div class="level-left">
    <div class="level-item">
    <p class="subtitle is-7 info date">
    {{ partial "traducir-fecha.html" .Date . }}
    </p>
    </div>
    </div>
    </div>
  </div>
</article>
<br>
{{ end }}
{{end}}
</ul>
{{ end }}
{{ partial "pagination.html"}}{{end}}
</section>
{{ end }}

Any idea or suggestions?

Without a proper sample that can be tested it’s hard to exactly point out what is going on, but I think that the moment where the first 5 is applied is already “inside” of a ranged page. So you need to cut out the 5 items first, then range over that. Maybe something like this:

{{ $fivePages := .Paginator.Pages.ByWeight | first 5 }}
{{ range $fivePages }}

It might work if you put brackets around the piping:

{{ range (.Paginator.Pages.ByWeight | first 5) }}

but this might be harder to read and understand if you look at it again in two years.

See this:

I have already identified the problem. It seems that the logic in this partial only allows me to have subsections or page bundles within a section, but it does not allow me to have subsections and page bundles at the same time.
The problem arises when I try to have a page bundle at the same level as a subsection. I need to modify the logic to allow me to list both.

Thanks for your comments…