.Prev & .Next Returning Opposite Of Expected

I am presently working through converting a template to get myself comfortable with Hugo. So far, almost everything is great and I’m really loving what Hugo offers.

I’ve run into one question and it’s in regards to the usage of .Next and .Prev. I’ve utilized these on a single.html (_default) as I haven’t bothered implementing anything else yet.

Here is what my implementation looks like:

{{ if .Prev }}
<li class="prev"><a rel="prev" href="{{.Prev.Permalink}}"><strong>Previous Article</strong>{{.Prev.Title}}</a></li>
{{ end }}
{{ if .Next }}
<li class="next"><a rel="next" href="{{.Next.Permalink}}"><strong>Next Article</strong>{{ .Next.Title }}</a></li>
{{ end }}

The part that is confusing for me is that the Prev link that ends up rendering is for a newer article/post and vice-versa.

I’ve verified that the front-matter on my posts includes dates that progress expectedly but they’re still rendering oddly from my perspective.

I realize that to change the behavior I could simply switch the calls for Prev/Next but I’m wanting to see if there is something that I’m not understanding or missing.

Thanks in advance for your insight!


1 Like