Should .Prev and/or .Next be empty?

Hello,

I have 6 posts on my new website. I run Hugo with:

hugo server --baseUrl=http://localhost/ --buildDrafts --buildFuture

In my _default/single.html I have:

<div class="post-navigation">
Previous: {{ if .Prev }} {{ printf "%#v" .Prev.Title }} {{ end }} <br/>
Next: {{ if .Next }} {{ printf "%#v" .Next.Title }} {{ end }}
</div>

The posts have the following publish dates:

  • 9 July
  • 10 July
  • 10 August
  • 20 September
  • 11 October
  • 30 December

Oddly enough, the 10 July post doesn’t have a “next post” whereas the 10 August post doesn’t have a “previous post”.

According to the documentation, .Next and .Prev are based on publication date:

.Prev Pointer to the previous content (based on pub date).
.Next Pointer to the following content (based on pub date).

So what can cause two of my middle posts to have an empty .Next and .Prev?

Thanks in advance for any insight.

If I change the date setting in the front matter to that of the publishdate, then .Next and .Prev return valid values. Perhaps the documentation should read that these return “based on date” and not ‘pub date’?

This would mean I can’t use publishdate, so I hope there’s a workaround.


Another thing I noticed on Hugo 0.16 is that .Next returns the previous content with a later date (based on date, not publishdate) whereas .Previous returns the next (that is, the older content).

For example, on my 10 August post, this:

    <div class="post-navigation">
    Previous: {{ if .Prev }} {{ .Prev.Date }} {{ end }} <br/>
    Next: {{ if .Next }} {{ .Next.Date }} {{ end }}
    </div>

Prints:

Previous: 2016-09-20 00:00:00 +0000 UTC
Next: 2016-07-10 00:00:00 +0000 UTC

I would assume here that 20 September is “next to” 10 August, whereas 10 July would be “previous to” 10 August. But it seems to be the other way around.