-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redo author configuration #19
Comments
Interesting. Yeah, the author handling needs a standard approach across themes. Don't know if one has been settled on. Perhaps raise an issue on the hugo repo itself as well? |
@ryanwalls yeah, Author config has really been a pain point. I've tried to be flexible on the theme and allow multiple-authors and additional metadata. Looks like there are some gears turning for some kind of official support in version 0.17 of hugo: I think you commented on this as well, so you are probably aware. It turns out that you can't define custom template functions without forking Hugo, something I'm definitely not interested in pursuing as it will break downstream users (unless they also use my fork). So I'm going to hold off on this work until 0.17 when we have some official view on this from Hugo itself crosses fingers. |
Closing this issue. Author metadata is still awkward, but I think we have it in a good state until the official adoption of a standard in hugo: |
Right now we configure
author
in two places:Site.Params
section where there is a singleauthor
param. This serves two functions: it sets the "default" author for posts when no author is set in a piece of content and, when no details are set (see below) it also is what is used for the text of the author on posts.Site.Author
map. This serves as a lookup for all available authors on the site and allows us to provide more detail about authors. We can set their location/bio/thumbnail, etc. here. We try to lookup this detail based on the author key that is set on any contnent, and if not set, we use whatever is set inSite.Params
This setup makes it very confusing for the templates to figure out what is going on with a configuration. Every time we want to show some author data, we have to go thru the following process:
Site.Author
configuration.Site.Params.Author
is set. If so we use that as the key and repeat steps 1-2.Site.Author
map, we then fallback to using the key value as the "name" parameter in the templates.That's a lot for templates to have to manage.
I'd like to simplify this considerably by introducing a template function that can encapsulate all the logic of figuring out author metadata and just return it back to the caller. If anything is not set, it defaults to the empty string. This will remove all the safety checks we currently have to write in individual templates and move it to a place where it can be reused.
I'm not sure if Hugo allows themes to write custom functions, but I'm going to try.
The text was updated successfully, but these errors were encountered: