# Hugo paginator add pages?

**URL:** <https://discourse.gohugo.io/t/hugo-paginator-add-pages/26341>\
**Category:** support\
**Tags:** pagination\
**Created:** [June 18, 2020, 9:26am UTC](https://discourse.gohugo.io/t/hugo-paginator-add-pages/26341 "2020-06-18T09:26:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![OjunbamO](https://avatars.discourse-cdn.com/v4/letter/o/bbce88/32.png) [@OjunbamO](https://discourse.gohugo.io/u/OjunbamO)\
**Post date:** [June 18, 2020, 9:26am UTC](https://discourse.gohugo.io/t/hugo-paginator-add-pages/26341/1 "2020-06-18T09:26:31Z")

</div>

Hello guys,  
I just wanted to build a little pagination for my blog. Currently hugo will load all markdown files from the $ directory. For the “Snipppets” section the pagination works fine.

 ![Screenshot 2020-06-18 at 11.14.57](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/9/973654b84257a24705887cb46ad745332e4e3f46.png)

The structure is like:  
/content/snippets/post1.md  
/content/snippets/post2.md  
/content/snippets/post3.md

But for the “Hub” section I got some “series posts” and the paginator doesn’t understand that the pages are in subdirectorys.

 ![Screenshot 2020-06-18 at 11.18.50](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/3/367dc6f6f0f9268abb7ffcf789cd15811ba07108.png)

The structure is like:  
/content/hub/series1/post1/\_index.md  
/content/hub/series1/post2/\_index.md  
/content/hub/series2/post1/\_index.md  
/content/hub/series2/post2/\_index.md

The code for the pagination:

```auto
{{ $pag := $.Paginator }}
{{ $pag }}
{{ if gt $pag.TotalPages 1 }}

<div class="section-xs">
	<div class="container" style="text-align: center;">
		<div class="pagination-wrapper margin-0">
			<div class="pagination">
				<a class="prev page-numbers" {{ if $pag.HasPrev }}href="{{ $pag.Prev.URL }}"{{ end }}><<</a>

				{{ range $pag.Pagers }}
					{{ if eq . $pag }}
					<span aria-current="page" class="page-numbers current">{{ .PageNumber }} </span>
					{{ else }}
					<a class="page-numbers" href="/snippets/page/{{ .PageNumber }}">{{ .PageNumber }}</a>
					{{ end }}
				{{ end }}

				<a class="next page-numbers" {{ if $pag.HasNext }}href="{{ $pag.Next.URL }}"{{ end }}>>></a>
			</div>
		</div>
	</div>
</div>
{{ end }}

```

Can I count/add some pages to the paginator with a `{{ range }}` function or is the paginator also able to range also through subdirectorys? In the documentation I can’t find something usefull.

Regards  
OjunbamO

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 18, 2020, 9:58am UTC](https://discourse.gohugo.io/t/hugo-paginator-add-pages/26341/2 "2020-06-18T09:58:44Z")

</div>

> [@OjunbamO](#):
>
> In the documentation I can’t find something usefull.

What you want to look into is the `.Paginate` method – which allows to paginate any page collection you want, e.g.:

{{ $pag := $.Paginate site.RegularPages }}

---

<div class="post-metadata">

**Author:** ![OjunbamO](https://avatars.discourse-cdn.com/v4/letter/o/bbce88/32.png) [@OjunbamO](https://discourse.gohugo.io/u/OjunbamO)\
**Post date:** [June 18, 2020, 12:25pm UTC](https://discourse.gohugo.io/t/hugo-paginator-add-pages/26341/3 "2020-06-18T12:25:16Z")

</div>

> [@bep](#):
>
> {{ pag := .Paginate site.RegularPages }}

{{ $paginator := .Paginate (where .Site.RegularPages “Section” “hub”) }}  
I tried it with something like this, but it also shows the same.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [June 18, 2020, 5:08pm UTC](https://discourse.gohugo.io/t/hugo-paginator-add-pages/26341/4 "2020-06-18T17:08:08Z")

</div>

Then you need to check if you have .Paginate (or .Paginator) called earlier in the template(s), as the paginator is static (1 per page and the first will win).
