So, an update (that was an interesting look into Hugo code, Go and Git)
The new compiled master works well, but of course I’ve got Title set in the front matter, so it was sorting by that. Works great when I remove title.
Therefore, as an experiement, and to be able to use title in front matter and also sort by file path, I added a new function to the file you modified, on my local Hugo source (I’m not familiar with cloning, comitting, etc in github).
So I compiled this local version and this new function seems to work ok, thanks to your modified code as a guide (as I have no prior knowledge of Go).
New function I put in pageSort.go is:
// ByFilePath sorts the Pages by file path and returns a copy.
//
// Adjacent invocactions on the same receiver will return a cached result.
//
// This may safely be executed in parallel.
func (p Pages) ByFilePath() Pages {
key := “pageSort.ByFilePath”
FullFilePath := func(p1, p2 *Page) bool { return p1.FullFilePath() < p2.FullFilePath() }
pages, _ := spc.get(key, p, PageBy(FullFilePath).Sort) return pages
}
and I’'ve tested it like this:
{{ range where $.Site.Pages.ByFilePath "Section" "product" }}
and it seems to work.
If anyone else wants this or if I can / should include in github version, let me know.