I’m working on authors pages for a site. I want the authors/ page to show all authors ordered by number of posts, and I want to see their names instead of the slugified/urlized version, so I’m using this in terms.html:
My problem is that even the humanize+ title combination doesn’t give me the actual names, e.g. Jane McDonald becomes Jane Mcdonald. How could I access the Params.name of each terms page from within this loop? I’ve tried various things without success.
What does $name return, without processing it through title? Should just be Jane McDonald, correct?
Edit: what I mean is, you are transforming the person’s name for the URL, and then trying to turn it back. But you can create those two values separately, rather than one based on the other.
Sorry and thanks, now I see what you mean by name. The metadata files for authors (in content/authors) have a name… but not a title so I’ll experiment with that, in hindsight name was a bad parameter name!
when printing variables in scope (see above) I only got the term name (“jane-mcdonald”) and the pages where she is an author, not anything related to the metadata, but I’ll try again with title
And the corresponding deployed authors page https://5c32f4a29066928a5b050341–focused-haibt-674433.netlify.com/authors/ where I printed the variables in scope, terms name and pages authored by the author corresponding to the term.
From within the loop, I don’t have access to authors metadata (even after adding title).
If I replace .Data.Terms.ByCount with .Data.Pages I do have access to the authors metadata, so it’s a feature of .Data.Terms I suppose. What I’d like is the best of both, the ordering by count and the count, and all the metadata.
My current best guess is looping over all website pages for each term, to find the corresponding author page.
I only nearly works because the RelPermalink variable has a different encoding so for Jäne McDonald it’s /authors/j%C3%A4ne-mcdonald/ whereas the name I’m comparing it to is /authors/jäne-mcdonald/ See current state of https://github.com/maelle/multiauthors-site and preview at https://5c3306a1eed26100078411b6–focused-haibt-674433.netlify.com/authors/
I’m giving up for now, I hope I’m only missing an obvious way to access authors metadata from within .Data.Terms.ByCount.
I had actually seen the option yesterday but in the context of https://github.com/gohugoio/hugo/issues/2835 so I thought it no longer existed! After looking at the Hugo repo I see it was then re-added.
I guess this solves my problem by making it useless for me to access term metadata from within .Data.Terms.ByCount loop, but if I were to need the Twitter username of authors in terms.html, I’d use $Site.GetPage which is also something I had missed earlier.