# Question regarding Next Prev navigation

**URL:** <https://discourse.gohugo.io/t/question-regarding-next-prev-navigation/1055>\
**Category:** support\
**Created:** [April 15, 2015, 3:25pm UTC](https://discourse.gohugo.io/t/question-regarding-next-prev-navigation/1055 "2015-04-15T15:25:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [April 15, 2015, 3:25pm UTC](https://discourse.gohugo.io/t/question-regarding-next-prev-navigation/1055/1 "2015-04-15T15:25:36Z")

</div>

From what I’ve seen at the Hugo Docs repository the next and the previous url paths are specified on the front matter of each post. For example:

```
---
next: /extras/builders
prev: /taxonomies/ordering
title: Aliases
weight: 10
---

```

Is this the only way to do this? Or is there some other way to get this functionality without specifying the url paths on every post?

---

<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:** [April 15, 2015, 4:11pm UTC](https://discourse.gohugo.io/t/question-regarding-next-prev-navigation/1055/2 "2015-04-15T16:11:50Z")

</div>

There are many ways two rome.

- .Next, .Prev
- .NextInSection, .PrevInSection
- And @spf13’s undocumented new feature

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [April 15, 2015, 5:05pm UTC](https://discourse.gohugo.io/t/question-regarding-next-prev-navigation/1055/3 "2015-04-15T17:05:14Z")

</div>

An undocumented feature? Care to elaborate? Is this implemented on a website that I can look at?

I’m thinking about migrating my drawing blog to hugo and since I have some 350 posts entering those path urls manually seems like overkill.

---

<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:** [April 15, 2015, 6:25pm UTC](https://discourse.gohugo.io/t/question-regarding-next-prev-navigation/1055/4 "2015-04-15T18:25:39Z")

</div>

The first two options is documented. Use the search on the doc site.

The last one I believe is undocumented, but if you read Go code, see this commit:

> <https://github.com/gohugoio/hugo/commit/b719ba7e2bd612e85e539b17569ed15066ebcc07>

---

<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:** [April 15, 2015, 7:56pm UTC](https://discourse.gohugo.io/t/question-regarding-next-prev-navigation/1055/5 "2015-04-15T19:56:38Z")

</div>

Theres also

> **[Pagination](http://gohugo.io/templates/pagination/)**
>
> Hugo supports pagination for your homepage, section pages, and taxonomies.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [April 18, 2015, 12:16pm UTC](https://discourse.gohugo.io/t/question-regarding-next-prev-navigation/1055/6 "2015-04-18T12:16:38Z")

</div>

Thanks for your pointers bjornerik.

I found that the following code does what I need.  
I’m posting it here just in case someone else needs it. It goes in single.html

```
{{ if .PrevInSection }}
<a href="{{.PrevInSection.Permalink}}">Previous Post</a>
{{ end }}
{{ if .NextInSection }}
<a href="{{.NextInSection.Permalink}}">Next Post</a>
{{ end }}
```

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [May 7, 2020, 8:02pm UTC](https://discourse.gohugo.io/t/question-regarding-next-prev-navigation/1055/7 "2020-05-07T20:02:17Z")

</div>

Archived on May 7, 2020, 8:02pm UTC


