# How to perform pagination under taxonomy.html?

**URL:** <https://discourse.gohugo.io/t/how-to-perform-pagination-under-taxonomy-html/55419>\
**Category:** support\
**Tags:** taxonomy, pagination\
**Created:** [July 25, 2025, 1:47pm UTC](https://discourse.gohugo.io/t/how-to-perform-pagination-under-taxonomy-html/55419 "2025-07-25T13:47:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sidoki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sidoki/32/24925_2.png) [@sidoki](https://discourse.gohugo.io/u/sidoki)\
**Post date:** [July 25, 2025, 1:47pm UTC](https://discourse.gohugo.io/t/how-to-perform-pagination-under-taxonomy-html/55419/1 "2025-07-25T13:47:28Z")

</div>

I’m trying to paginate using following codes

```auto
{{ $maxPage := 20 }}
{{ $paginator := .Paginate .Data.Pages $maxPage }}

{{ range $paginator.Pages }}
{{ . }}
{{ end }}

{{ partial "pagination.html" . }}

```

Above code will throw me error like below:

```auto
execute of template failed – is nil; wrap it in if or with: {{ with }}{{ .Pages }}{{ end }} 

```

I’m not sure what’s happening. When I’m trying to loop without pagination, it works

```auto
{{ range .Data.Pages }}
{{ . }}
{{ end }}

```

I’m using the latest hugo version: hugo v0.148.1

Please help @bep, @jmooring and others, thanks!

---

<div class="post-metadata">

**Author:** ![sidoki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sidoki/32/24925_2.png) [@sidoki](https://discourse.gohugo.io/u/sidoki)\
**Post date:** [July 25, 2025, 2:11pm UTC](https://discourse.gohugo.io/t/how-to-perform-pagination-under-taxonomy-html/55419/2 "2025-07-25T14:11:48Z")

</div>

> [@sidoki](#):
>
> ```auto
> 
> ```

I found the solution after following this [past discussion](https://discourse.gohugo.io/t/pagination-not-working-on-term-html/36093).

Turns out, you need to explicitly declare the pagination in the range syntax like below:

```auto
{{ range (.Paginate .Data.Pages).Pages }}
{{ . }}
{{ end }}

```

I’m not sure about the the reason behind this. Is it because the variable make the paginator object static?

---

<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:** [July 25, 2025, 2:42pm UTC](https://discourse.gohugo.io/t/how-to-perform-pagination-under-taxonomy-html/55419/3 "2025-07-25T14:42:37Z")

</div>

Your original code works fine. Try it:

```plaintext
git clone --single-branch -b hugo-forum-topic-55419 https://github.com/jmooring/hugo-testing hugo-forum-topic-55419
cd hugo-forum-topic-55419
hugo server

```

Files of interest:

- `layouts/taxonomy.html`

---

<div class="post-metadata">

**Author:** ![sidoki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sidoki/32/24925_2.png) [@sidoki](https://discourse.gohugo.io/u/sidoki)\
**Post date:** [July 26, 2025, 2:50am UTC](https://discourse.gohugo.io/t/how-to-perform-pagination-under-taxonomy-html/55419/4 "2025-07-26T02:50:37Z")

</div>

Ok, thanks @jmooring !

---

<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:** [July 28, 2025, 2:50am UTC](https://discourse.gohugo.io/t/how-to-perform-pagination-under-taxonomy-html/55419/5 "2025-07-28T02:50:54Z")

</div>

Closed on July 28, 2025, 2:50am UTC

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