Is there any way to do something like .PrevInType?

I’m listing different content that has the same type, and i need to add a “Next” and “Previous” button. It’s possible?

There are NextInSection and PrevInSection.

Yeah, but I’m listing contents of different sections that have the same type. So I would like something .PrevInType and .NextInType.

Ideas?

There are some undocumented methods on the page collections: .Next and … Prev.

These are undocumented because … They have a slightly funky API and I have been wanting to replace it with something better. But time is a limit. But if you can read GoDoc: https://github.com/gohugoio/hugo/blob/master/hugolib/pagesPrevNext.go#L30

Note that these will start at the beginning when they reach the end, which is one of the confusing things about it. But you should be able to do next/prev on almost anything.

1 Like

This works for me:

Thanks!