# \[SOLVED \]A Paginator was previously built for this Node

**URL:** <https://discourse.gohugo.io/t/solved-a-paginator-was-previously-built-for-this-node/5072>\
**Category:** support\
**Tags:** pagination\
**Created:** [January 8, 2017, 11:48pm UTC](https://discourse.gohugo.io/t/solved-a-paginator-was-previously-built-for-this-node/5072 "2017-01-08T23:48:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![brunoamaral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/brunoamaral/32/21144_2.png) [@brunoamaral](https://discourse.gohugo.io/u/brunoamaral)\
**Post date:** [January 8, 2017, 11:48pm UTC](https://discourse.gohugo.io/t/solved-a-paginator-was-previously-built-for-this-node/5072/1 "2017-01-08T23:48:19Z")

</div>

I’m trying to display certain blocks of html depending on whether it’s the homepage or not.

To do that, I’m using the following:

`{{ if eq .Paginator.PageNumber 1 }} <h2 class="only-small align-center">Stories</h2> (...) {{ end }}`

However, I sometimes get the error: “a Paginator was previously built for this Node”. I’m guessing this happens because I can only call .Paginator once per page. If so, what’s the right way to do this check?

Update: I’m now trying to use {{ if .IsHome }} but no luck. Maybe because the instruction is inside a partial.

---

<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:** [January 9, 2017, 12:42am UTC](https://discourse.gohugo.io/t/solved-a-paginator-was-previously-built-for-this-node/5072/2 "2017-01-09T00:42:53Z")

</div>

You can call .Paginator as many times you want – but there is a ordering issue here that you must look into.

- You have called .Paginator (which uses .Data.Pages)
- Then you have called .Paginate with a custom page selection

The selection is static, so you cannot change your mind.

---

<div class="post-metadata">

**Author:** ![brunoamaral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/brunoamaral/32/21144_2.png) [@brunoamaral](https://discourse.gohugo.io/u/brunoamaral)\
**Post date:** [January 11, 2017, 11:38am UTC](https://discourse.gohugo.io/t/solved-a-paginator-was-previously-built-for-this-node/5072/3 "2017-01-11T11:38:03Z")

</div>

@bep I have been trying to understand this issue and I still have doubts.

In fact I do have a .Paginate after that code:

```
{{ if eq .Paginator.PageNumber 1 }}
	<h2 class="only-small align-center">Latest post</h2>
{{ end }}
{{ range (.Paginate (where .Data.Pages "Type" "post") 1).Pages }}
	<div class="mini-posts only-small">
	<article class="mini-post stories only-small">
		<header>
			<p>{{ .Date.Format "January 2, 2006" }}</p>
		</header>
		<a href="{{ .Permalink }}" class="image mini-featured-image" style="background-image: url('{{ .Site.BaseURL }}{{ .Params.featured_image }}'); background-position: 40% 40%;"><h3 style="background-color: rgba(255,255,255,0.7)">{{ .Title }}</h3></a>
	</article>
	</div>
{{ end }}

```

There is yet another instance of {{ range }}, with the same query, in the index. Yet from what you’re telling me, this will cause conflicts.

What is then the correct approach?

---

<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:** [January 11, 2017, 12:40pm UTC](https://discourse.gohugo.io/t/solved-a-paginator-was-previously-built-for-this-node/5072/4 "2017-01-11T12:40:53Z")

</div>

> [@brunoamaral](#):
>
> (.Paginate (where .Data.Pages “Type” “post”) 1)

Create the paginator before its used, and put it into a variable.

---

<div class="post-metadata">

**Author:** ![brunoamaral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/brunoamaral/32/21144_2.png) [@brunoamaral](https://discourse.gohugo.io/u/brunoamaral)\
**Post date:** [January 11, 2017, 2:41pm UTC](https://discourse.gohugo.io/t/solved-a-paginator-was-previously-built-for-this-node/5072/5 "2017-01-11T14:41:04Z")

</div>

thank you for clearing that up 🙂
