If you want the next page in the section which does not have a certain value for a parameter, you may need to use a recursive partial. This is because .NextInSection is not a collection that you can filter, but just a single page.
Here’s an example of how you could create a recursive partial
// in the base template
{{ partial "nextpage" . }}
// in /layouts/partials/nextpage.html
{{ with .NextInSection }}
// Check if the next page is a teaser
{{ if eq .Params.Type "teaser" }}
// if so, try the next next page (this creates recursion)
{{ partial "nextpage" . }}
{{ else }}
// otherwise render the next page link
<a href="{{ .RelPermalink }}"> Next Page </a>
{{ end }}
{{ end }}
Thanks for this - I got it to work easily - and as my teaser pages are “at the end” of the list because of hugos default sorting by weight/date/name (teaser pages having associated weight - other pages in the blog section do not) I could do without the recursion in this case
I tried many things to get this to work - no success.
{{ range .Site.Pages }}
gives all pages, not only the ones of the blog section (as expected).
{{ range .Data.Pages }}
doesn’t give any pages …
I then tried to do something like - in words “range .Site.Pages where section blog and type ne ‘teaser’” in many different ways but hugo kept complaining about wrong number of arguments etc. … til I gave up.