Is it possible to range through pages by title while omitting any leading articles like The, An, or A? For example, if I have three pages named “Something Great”, “Another Post”, and “The Beginning”, sorting by page title would yield:
Another Post
The Beginning
Something Great
Currently, Hugo will put “The Beginning” after “Something Great”. I’d like to be able to drop those small leading words that typically don’t get alphabetized.
We don’t have a built-in sorting implementation for that. You’d need to range through the pages and create a dictionary with your trimmed titles as the key.
Do you happen to have a link that goes into the range function? I have to admit, I can’t quite wrap my head around using more than a basic {{ range .Pages }} ... {{ end }}, so using keys and values in my range is beyond my current understanding.
{{ range partial "sort-title" .Pages }}
...
{{ end }}
The trimming isn’t very intelligent. It’s case sensitive, and there’s a possibility (however remote) that some titles could be overly trimmed. However, it seems to get the job done.