# Paginator in section template now working?

**URL:** <https://discourse.gohugo.io/t/paginator-in-section-template-now-working/31787>\
**Category:** support\
**Tags:** pagination\
**Created:** [March 17, 2021, 2:39am UTC](https://discourse.gohugo.io/t/paginator-in-section-template-now-working/31787 "2021-03-17T02:39:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zuramai](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/zuramai/32/13857_2.png) [@zuramai](https://discourse.gohugo.io/u/zuramai)\
**Post date:** [March 17, 2021, 2:39am UTC](https://discourse.gohugo.io/t/paginator-in-section-template-now-working/31787/1 "2021-03-17T02:39:11Z")

</div>

Does anyone know why paginator in section template is not working?  
I have this directory structure

```auto
- content
    - articles
        .....my content
- layouts
    - _default
        - section.html

```

In `section.html`, when I use `{{ range .Pages }}` its work fine with displaying all pages within that section. But when I change it to `{{ range .Paginator.Pages }}` returns empty.

And my paginator in taxonomy page `list.html` working fine. I wondering why my code doesn’t work ☹

Theme repository: [https://github.com/zuramai/hugoblog/](https://github.com/zuramai/hugoblog/)

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 17, 2021, 3:00am UTC](https://discourse.gohugo.io/t/paginator-in-section-template-now-working/31787/2 "2021-03-17T03:00:44Z")

</div>

See [https://discourse.gohugo.io/t/requesting-help/9132](https://discourse.gohugo.io/t/requesting-help/9132)

> 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.

---

<div class="post-metadata">

**Author:** ![zuramai](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/zuramai/32/13857_2.png) [@zuramai](https://discourse.gohugo.io/u/zuramai)\
**Post date:** [March 17, 2021, 3:32am UTC](https://discourse.gohugo.io/t/paginator-in-section-template-now-working/31787/3 "2021-03-17T03:32:04Z")

</div>

I have edited my post, this is my repository  
[https://github.com/zuramai/hugoblog/](https://github.com/zuramai/hugoblog/)

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 17, 2021, 3:48am UTC](https://discourse.gohugo.io/t/paginator-in-section-template-now-working/31787/4 "2021-03-17T03:48:08Z")

</div>

```bash
hugo new site foo
cd foo
git init
git submodule add https://github.com/zuramai/hugoblog/ themes/hugoblog

```

config.toml

```auto
baseURL = "http://example.org/"
languageCode = "en-us"
title = "My New Hugo Site"
theme = "hugoblog"

```

Then I generated 20 articles:

```auto
content
└── articles
    ├── articles-01.md
    ├── articles-02.md
    ├── articles-03.md
    ├── articles-04.md
    ├── articles-05.md
    ...

```

Now build…

```bash
hugo

```

Result:

```auto
Start building sites … 
Total in 35 ms
Error: Error building site: failed to render pages: render of "home" failed: execute of template failed: template: index.html:23:31: executing "main" at <partial "card/card-horizontal-mini.html" .>: error calling partial: "/home/jmooring/temp/joe/themes/hugoblog/layouts/partials/card/card-horizontal-mini.html:25:29": execute of template failed: template: partials/card/card-horizontal-mini.html:25:29: executing "partials/card/card-horizontal-mini.html" at <first 1 .Params.categories>: error calling first: both limit and seq must be provided

```

Please fix the error, update your repo, then let me know.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 17, 2021, 4:35am UTC](https://discourse.gohugo.io/t/paginator-in-section-template-now-working/31787/5 "2021-03-17T04:35:23Z")

</div>

`layouts/_default/section.html` is called when generating `articles/index.html`.

`layouts/_default/section.html` template does this:

```auto
{{ range .Paginator.Pages }}
  {{ partial "card/card-horizontal.html" . }}
{{ end }}

```

But, before it does that, it does this:

```auto
{{- partial "head.html" . -}}

```

`layouts/partials/head.html` does this:

```auto
{{ if eq .Section "articles" }} 
  <!-- Pagination meta tags for list pages only -->
  {{ $paginator := .Paginate (where .Pages "Section" "blog") }}
  {{ if $paginator }}
    ...
    ...
  {{end }}
  ...
  ...
{{ end }}

```

You can’t do that.

From [https://gohugo.io/templates/pagination/#list-paginator-pages](https://gohugo.io/templates/pagination/#list-paginator-pages):

> For a given **Page** , it’s one of the options above. The `.Paginator` is static and cannot change once created.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [March 17, 2021, 4:38am UTC](https://discourse.gohugo.io/t/paginator-in-section-template-now-working/31787/6 "2021-03-17T04:38:29Z")

</div>

Here’s a similar issue:

> [@$paginatorTitle := .Paginate - twice](https://discourse.gohugo.io/t/solved-paginatortitle-paginate-twice/27986):
>
> Hello. I add code in header.html {{ $paginatorTitle := .Paginate (where (where .Site.RegularPages.ByDate.Reverse "Type" "blog") "Params.hide\_public" false) }} {{ if (le 2 $paginatorTitle.PageNumber) }} - {{ T "Page\_Number" }} {{ $paginatorTitle.PageNumber }}{{ end }} And add the code in blog Section tpl. {{ $paginator:= .Paginate (where (where .Site.RegularPages.ByDate.Reverse "Type" "blog") "Params.hide\_public" false) }} {{ range $k, $v := $paginator.Pages }} {{ .Render "b…

---

<div class="post-metadata">

**Author:** ![zuramai](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/zuramai/32/13857_2.png) [@zuramai](https://discourse.gohugo.io/u/zuramai)\
**Post date:** [March 17, 2021, 5:41am UTC](https://discourse.gohugo.io/t/paginator-in-section-template-now-working/31787/7 "2021-03-17T05:41:37Z")

</div>

SOLVEDD!  
I just deleted my Paginator in `head.html` and it works fine! So the conclusion is I can’t use two paginator in one page.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [March 19, 2021, 5:41am UTC](https://discourse.gohugo.io/t/paginator-in-section-template-now-working/31787/8 "2021-03-19T05:41:59Z")

</div>

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