Please let me know if I’m mistaken and there’s already a way to do what I’m asking. Basically, I would like a way to indicate how a term should be sorted.
To see what I mean, imagine there are taxonomies title
and authors
and there’s a page titled the-winters-tale.md
as follows:
+++
[taxonomies]
title = ["The Winter's Tale"]
authors = ["William Shakespeare"]
+++
How would one reliably sort this as Shakespeare, William? I don’t think there’s currently a good way to do this.
Of course you can store authors = [“Shakespeare, William”] , but then you don’t really have it in the “{{ first }} {{ last }}"
format.
Furthermore, this is more of a hack than anything, as it wouldn’t work for many titles.
Imagine, for example, the term “The Good, The Bad, and the Ugly”
for the titles
taxonomy. This should be sorted like ”Good, The Bad, and The Ugly, The”
, but because commas are in the title you can’t really reliably do what worked before with author names.
The popular OSS book management software “calibre” has to deal with sorting a lot more than Zola, and so I think its solution could be good inspiration. It just has a separate key for title and author sort. See the image below:
With this in mind, I think a similar approach could be used for taxonomical terms in Zola. It may look, for example, like this:
+++
[[taxonomies.authors]]
term = "William Shakespeare"
sort = "Shakespeare, William"
taxonomies.title = ["The Winter's Tale"]
+++
This would allow there to be the term as you’d like it displayed, as well as the canonical way to sort this. Additionally, in my example the title
taxonomy remains an array of strings, like how it is today. The idea is both would work, with the term
+ sort
keys being optional.
I believe something like this would be very useful for the project, in particular when working in taxonomies, although the idea could be extended to page titles as well and even made to integrate with the page sorting options that are provides already.