Accessing .NextInSection.Title in single.html template causes error: "can't evaluate field Title in type *hugolib.Page"

I have a “Posts” content directory that holds a series of posts markdown files and a single.html template in my default layouts directory. In the footer of my single.html template, I want to display the the titles of the next and previous posts in this section using <h1>{{ .NextInSection.Title }}</h1>. However, I keep getting the following error:
Error while rendering "page": template: /Users/jonathan/Desktop/portfolio-2018/layouts/_default/single.html:17:21: executing "main" at <.NextInSection.Title>: can't evaluate field Title in type *hugolib.Page

Not sure why I’m getting an error here. Thanks!

I’m not sure (I would expect some other error message …), but are you sure the next in section exists? What happens if you wrap it in:

{{ with .NextInSection }}{{ .Title }}{{ end }}

That worked, no error.

I have three content files in my Posts directory. Does .NextInSection wrap back to the first file after it reaches the last?