As always, any help is much appreciated. Am failing to get the result I expect, even when copying examples.
Edit to add: For anyone looking at this who doesn’t want to read the full discussion.
- Reverting to 0.54.0 fixed the first problem (it now correctly detects that it’s in a section)
- However, adding weights to the pages in the section does not get the expected result. According to the docs, lowest weight comes first, but as far as I can tell, it is doing the reverse of that.
Lists of content in Hugo | Hugo
So given:
page one - weight 100
page two - weight 200
page three - weight 300
On page two, .PrevInSection will be page three, and .NextInSection will be page one.
However, the following lists them in the order you’d expect (lowest weight first):
{{ range .Paginator.Pages }}
{{ end }}
I’m trying to add prev/next links for some tutorials. There are three tutorials, nested under a /tutorials directory:
content
tutorials
tutorial_one
tutorial_two
I found .NextInSection and .PrevInSection, but they are not working as expected. Thus:
{{ if .NextInSection }}
// do stuff
{{ end }}
In a page with siblings, still doesn’t show.
I am wondering if either of the following cause the problem:
(1) I am managing my menus and page ordering in the config.yaml. Each page has a weight assigned there. Could this be causing confusion? So perhaps .NextInSection doesn’t know about the page order?
(2) This suggests there can be some ambiguity with nested sections: Sections | Hugo
.CurrentSection gives the actual current section, while .Section gives the root section. If .NextInSection relies on .Section, then how do we do next/prev in nested sections?