What's the difference passing variables to .Paginate in a section template and a partial?

I have the following section structure

 |__  _index.md
 |__ subsection-a
       |__   _index.md
 |__ subsection-b
       |__   _index.md
 |__ subsection-c
       |__ _index.md

In _index.md of section-one, I tried using .Paginate, and it works

{{with $paginator  := .Paginate .Sections }}
              {{ range  $paginator.Pages }}
                <li><a href={{ .RelPermalink | relLangURL }}>{{ .Title }}</a></li>
            {{ end }}
             Pages: {{ $paginator.PageNumber }} / {{ $paginator.TotalPages }}

then I tried moving the snippet to a partial, and changed the first line to

{{with $paginator  := .Paginate . }}

so I can pass in .Sections like this {{ partial "paginate.html" .Sections }} in my section template.

But then I get this error:

can’t evaluate field Paginate in type page.Pages

I have no prior experience with Go and Go Template before I found Hugo, so I’m pretty new to all of this.
In my mind, I’m passing .Sections to .Paginate function in both cases, but that doesn’t seem to be the case. Can anyone enlighten me on what’s going on under the hood?

You need to paginate on one page, not many. Change it to {{ partial "paginate.html" .}} or something and it will work.

1 Like

Ah…that’s why. Thank you!