Does .NextInSection work?

I am trying to place the {{.NextInSection}} in the section list template and i am getting as a result.

I even tried this on a fresh website with 2 content pages in a section called posts and am trying to call the {{.NextInSection}} in the default/single.html file.

Am i missing something??

Works fine for me.

You are a little bit unclear about what you get and what you expect.

I get nil as a value. Sorry, Nil is enclosed in html tag brackets which is not showing up in this comment editor because it is being interpreted as html.

Me too get nil as value when there is no next or prev.

Mentally this feature (same as Prev and Next) is a llitle backward … as next is older.

But I do have an older page within the section. I have 2 content pages. NextInSection on the newer page gives me nil and PrevInSection on this page doesn’t give me anything at all.

I actually get the opposite effect on the second page. NextInSection gives me nothing while PrevInSection gives me that nil value.

I feel like Im missing something. The only front matter i put in was a title and date.

You would have to put a failing project out in the open (GitHub?) for anyone to be able to guess whats up.

Do you have a typical example of how this should be done or a working project where this feature is being used so i can take a look myself? If not, I’ll check on Github.


Hmm… I notice now that .NextInSection works kind of differently from .Next.

This works for me:

 <a class="btn btn-lg cc-btn-default{{if not .PrevInSection}} disabled{{end}}" href="{{if .PrevInSection}}{{.PrevInSection.Permalink}}{{end}}">Older</a>
      <a class="btn btn-lg cc-btn-default{{if not .NextInSection}} disabled{{end}}" href="{{if .NextInSection}}{{.NextInSection.Permalink}}{{end}}">Newer</a>


Thanks bjornerik.This works for me now. Much appreciated.