# How to check if current page is homepage?

**URL:** <https://discourse.gohugo.io/t/how-to-check-if-current-page-is-homepage/23301>\
**Category:** support\
**Created:** [February 7, 2020, 10:30am UTC](https://discourse.gohugo.io/t/how-to-check-if-current-page-is-homepage/23301 "2020-02-07T10:30:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jura](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jura/32/13581_2.png) [@Jura](https://discourse.gohugo.io/u/Jura)\
**Post date:** [February 7, 2020, 10:30am UTC](https://discourse.gohugo.io/t/how-to-check-if-current-page-is-homepage/23301/1 "2020-02-07T10:30:51Z")

</div>

I want to run some Hugo template code on the homepage.

I use pagination and that gives me 5 index pages:

- `example.com/`
- `example.com/2/`
- `example.com/3/`
- `example.com/4/`
- `example.com/5/`

I want to run code only on the first of those. (That’s the actual homepage for me.) But how can I check that conditionally?

Page variables that I’ve tried:

- `.IsHome`; returns `true` on each of the five pages.
- `.RelPermalink`; is `/` on each page.
- `.Kind`; is `home` on each page.
- `.IsNode`; always `true` for each page.
- `.Permalink`; always the same on each page.

Hmm. 🤔 Anyone got an idea? 🙂

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [February 7, 2020, 10:51am UTC](https://discourse.gohugo.io/t/how-to-check-if-current-page-is-homepage/23301/2 "2020-02-07T10:51:57Z")

</div>

maybe:

```auto
{{ if and .IsHome ( eq $paginator.PageNumber 1 ) }}
  yo
{{ end }}

```

---

<div class="post-metadata">

**Author:** ![Jura](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jura/32/13581_2.png) [@Jura](https://discourse.gohugo.io/u/Jura)\
**Post date:** [February 7, 2020, 11:04am UTC](https://discourse.gohugo.io/t/how-to-check-if-current-page-is-homepage/23301/3 "2020-02-07T11:04:49Z")

</div>

Thanks for the quick reply!

Unfortunately I’m also looking to check if a page is the homepage _outside_ my pagination partial.

So `$paginator` isn’t available. And through `.Paginator` I can’t access the page number.

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [February 7, 2020, 11:07am UTC](https://discourse.gohugo.io/t/how-to-check-if-current-page-is-homepage/23301/4 "2020-02-07T11:07:59Z")

</div>

🤔

You got code I can play with?

---

<div class="post-metadata">

**Author:** ![Jura](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jura/32/13581_2.png) [@Jura](https://discourse.gohugo.io/u/Jura)\
**Post date:** [February 7, 2020, 11:30am UTC](https://discourse.gohugo.io/t/how-to-check-if-current-page-is-homepage/23301/5 "2020-02-07T11:30:52Z")

</div>

Unfortunately not, it’s a private project so far. Not even live yet.

Your comment gave me the idea to try scratch variables to get the `$paginator.PageNumber` value out from the pagination template.

That unfortunately only works for those theme templates that are called later in time. So for `footer.html` it works, but `sidebar.html` renders earlier than the pagination template, so the scratch variable is always empty there.

---

<div class="post-metadata">

**Author:** ![ShakataGaNai](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/shakataganai/32/10549_2.png) [@ShakataGaNai](https://discourse.gohugo.io/u/ShakataGaNai)\
**Post date:** [February 7, 2020, 5:31pm UTC](https://discourse.gohugo.io/t/how-to-check-if-current-page-is-homepage/23301/6 "2020-02-07T17:31:22Z")

</div>

I have a very similar issue. I want to modify the pagination count on the HOME homepage, not the rest of the pages.

(Edit remove the rest of my comment because morning…coffee…something)

---

<div class="post-metadata">

**Author:** ![divinerites](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/divinerites/32/12625_2.png) [@divinerites](https://discourse.gohugo.io/u/divinerites)\
**Post date:** [February 7, 2020, 5:32pm UTC](https://discourse.gohugo.io/t/how-to-check-if-current-page-is-homepage/23301/7 "2020-02-07T17:32:16Z")

</div>

> [@Jura](#):
>
> `.RelPermalink` ; is `/` on each page.

I guess this gives a hint that the code calling `.RelPermalink` do not reference the **actual** page.

---

<div class="post-metadata">

**Author:** ![Jura](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jura/32/13581_2.png) [@Jura](https://discourse.gohugo.io/u/Jura)\
**Post date:** [February 10, 2020, 5:34am UTC](https://discourse.gohugo.io/t/how-to-check-if-current-page-is-homepage/23301/8 "2020-02-10T05:34:15Z")

</div>

> [@divinerites](#):
>
> I guess this gives a hint that the code calling `.RelPermalink` do not reference the **actual** page.

That is odd, right?

I also checked with the following page variables, but those are also always the same on each paginated index page:

- `.Content`
- A custom param for the index page
- `.UniqueID` is also the same on each page.

> [@ShakataGaNai](#):
>
> I have a very similar issue. I want to modify the pagination count on the HOME homepage, not the rest of the pages.

Thanks, good to know I’m not the only one we tries to implement this. I’ve made a feature request here:

- [Provide a way to check homepage of paginated index #6876](https://github.com/gohugoio/hugo/issues/6876)

---

<div class="post-metadata">

**Author:** ![BobRock](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bobrock/32/24220_2.png) [@BobRock](https://discourse.gohugo.io/u/BobRock)\
**Post date:** [August 11, 2025, 6:07pm UTC](https://discourse.gohugo.io/t/how-to-check-if-current-page-is-homepage/23301/9 "2025-08-11T18:07:37Z")

</div>

I know this link is pretty old. But I wonder if there is a solution to the original problem now?

---

<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:** [August 11, 2025, 10:14pm UTC](https://discourse.gohugo.io/t/how-to-check-if-current-page-is-homepage/23301/10 "2025-08-11T22:14:30Z")

</div>

If you paginate _before_ the conditional, check the pager’s [`PageNumber`](https://gohugo.io/methods/pager/pagenumber/).

If you need to paginate _after_ the conditional, it gets complicated:  
[https://discourse.gohugo.io/t/pagination-using-pager-values-within-the-head-element/50340](https://discourse.gohugo.io/t/pagination-using-pager-values-within-the-head-element/50340)
