How to maintain order when I have subdirectories?

In the directory I have 5 posts and one subdirectory of

The 5 posts are sorted by date. But the weight nor Date frontmatter fields within the of the /optimizing-app-size directory isn’t factored in the ordering. The subdirectory just gets dumped at the end of the list.

When I attempt to change the weight of a single post within the /devtools directory, things work though.

This my

That’s the way the papermod theme builds its page collection: Override the template and sort the collection.

1 Like

Thank you so much. So the pages are sorted, but the combined $pages variable isn’t. Because I have ‘sorted pages, followed by sections’ which just get dumped? That makes perfect sense.

I ended up with the following:

{{- $pages := union .RegularPages .Sections}}
{{ $sortedPages := sort $pages "Params.weight"  ""}}

The signature of the sort function is:


So this doesn’t make any sense:

sort $pages "Params.weight"  ""}}

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.