Weird Prev/NextInSession behaviour

I have about 2000 posts in my blog. My post-pagination template looks like this:

<div class="row">
{{if .PrevInSection}}
  <div class="col-6">
    <i class="fas fa-arrow-left"></i>
    <a href="{{.PrevInSection.Permalink}}">{{.PrevInSection.Title}}</a>
  </div>
{{end}}
{{ if .NextInSection}}
  <div class="col-6 text-right">
    <i class="fas fa-arrow-right"></i>
    <a href="{{.NextInSection.Permalink}}">{{.NextInSection.Title}}</a>
  </div>
{{end}}
</div>

What happens is:

  • latest post has a PrevInSection link to second latest post
  • second latest post has a PrevInSection link to third latest post and NextInSection to latest post
  • third latest post has a PrevInSection link to the fourth latest post and NextInSection to second latest post
  • fourth latest post has a PrevInSection link to the fifth latest post and a NextInSection to the third latest post.

so far so good.

but now…

  • fifth latest post has no PrevInSection and NextInSection links.
  • subsequent posts have no prev/next either.

there is no difference in header meta data in these posts or anything that would imply some change of importance…

what is of interest is, that between the fifth and sixth post (in regards to publish time) is a post of another section. It feels like if the PrevInSection does not react if the “prev” is not in the “section” of the current section/type?