.Site.Authors not implemented?

Hello,

I was looking at the “twitter_cards” internal template, especially this part:

{{ range .Site.Authors }}
    {{ with .twitter -}}
        <meta name="twitter:creator" content="@{{ . }}"/>
    {{ end -}}
{{ end -}}

Source

I don’t understand Go language, but can sort of guess the syntax… I was looking at site.go, but looks like Authors variables of type AuthorList is only declared, but not assigned a value anywhere… is that right?

The reason I am posting this is that no matter how I define Authors (note: not Author) in my config.toml, the twitter_cards template is not picking those up.

One attempt:

[[Authors]]
  twitter = "foo"

Another attempt (anyways nothing worked, so just tried putting [Authors.Social] in there because author.go shows a Social var in Author struct:

[[Authors]]
  [Authors.Social]
    twitter = "foo"

I am making Authors a TOML Array of Tables, because that range says that that’s supposed to be an array of “author objects” (just like .Resources)… so am copying the TOML style of defining Resources in page front-matter.


  • Am I making a mistake in defining Authors in the config.toml?
  • Or should I be defining those there? (I assume so, because we are looking for .Site.Authors)
  • Or is really assigning values to .Site.Authors not implemented in hugo?

PS: The only thing I found in this forum was this similar, but unresolved thread.

1 Like

I’ve just spent the last half hour or so trying to figure this out myself.

It looks like it’s a half implemented feature that the developers just didn’t get around to hooking up. It seems that a number of the _internal templates use the .Site.Authors data - but then a lot of those aren’t documented either.

It’s a shame as an easy way to add author/s information to posts would be great!

Ah, that explains my failure to get that working when I was just starting up a few months ago. I thought I’d done something wrong as a beginner!

There are a few different ways to add author metadata to content. I use a taxonomy called authors, and that loads author bio blocks fine. :slight_smile:

Is there a write-up of that anywhere?

It is confusing because some of the Hugo documentation (if I remember rightly) refers to how to create author metadata but it doesn’t work.

I define my own structure for the .Site.Author in config.toml and use that in my custom partials that override the internal templates.

Example in config.toml:

[Author]  
  name = "Foo Bar" 
  email = "Foo.Bar@example.com"   
  bio = "Foo Bar's bio."  
  [Author.photo]    
    url = "images/me.jpg" 
    width = 400     
    height = 400

If you are dealing with multiple authors, you can instead create an array of such maps (tables of tables in TOML lingo) in the [Params] in config.toml.

There have been extensive conversations about authors implementation both here and in GitHub. I’m not exactly sure where things left off but there were some pretty good prototypes for multi-author blogs, with author profiles, floating around somewhere: https://discourse.gohugo.io/search?q=author.

Yeah, I figured out something in the end.

I’m not using a taxonomy, just a param, but the end result is author bio’s
:slight_smile:

2021 Update - Good News :tada:

There’s a detailed answer here: .Site.Author Usage? - #8 by jmooring

No official docs, but that guy put some docs together by inspecting how index.xml was built, so it’s probably as good as can be hoped for.