How to configure and use .Site.Author

I noticed in the documentation, that .Site.Author is a map of Authors specified in the config.toml file.

I also found this class which I think is supposed to be representing an author.

However, I can’t find an example of how to configure the list of authors, or how to the data in a template. Can someone please explain?

I’ve opened an issue 2282 on GitHub with what I think is related.

@DerekPerkins may help, but I’m not doing any work / creating any new GH issues about this until this is merged:

https://github.com/spf13/hugo/pull/1850

1 Like

Perfect. That was the missing link. I was just so shocked to see the author.go file in the repo, but not the rest of the support for using it.

Yes, the feature was started a while ago, but it is not documented because of its unknown state/likely to be changed.

No problem. I can wait, or roll my own support in a non-standard way in a theme I am converting.

In the meantime, I’ve proposed a technical bridge between the core of Hugo and Themes. You can read more over here: https://discuss.gohugo.io/t/theme-standardization-through-feature-support/3687

@pepper It’s pretty usable as it is right now. There’s some polish that needs to be added before formalizing it, but I was using it back in Feb just fine.

Really? Can you give me an example of what a config.tml file would look like with mulitple authors?

Also, do you mean it is usable with or without your Pull Request having been merged?

The PR would need to be merged, or if you built the binary from source, it’s not hard to merge in my PR yourself.

Here’s the directory layout with one file per author:

Then here is what the individual file looks like:

given_name		= "Derek"
family_name		= "Perkins"
display_name		= "Derek Perkins"
thumbnail		= "img link"
image			= "img link"
short_bio		= "super short bio"
bio			= "Here's Derek's awesome bio"
email			= "derek@email.com"

[social]
	facebook	= "https://www.facebook.com/derekperkins"
	github		= "https://github.com/derekperkins/"
	twitter		= "https://twitter.com/derek_perkins"
	googleplus	= "https://plus.google.com/+DerekPerkins1"

[params]
   random		= "whatever you want"
1 Like

Behind the scenes, it also tries to help standardize the actual social links. While the social networks have all standardized on some version of http(s) and/or www, people rarely respect those. The author package attempts to pull out the username, or even better, only have people add their username to the toml file, and then outputs the canonical social link.

If the eventual roadmap includes collapsing nodes and pages into a single model with extensible features / links, then authors with their own custom pages could be treated a bit more elegantly. May be a ways off, but wondering if that’s a priority at all?

1 Like