.Site.Author Usage?

Update 2024-03-31T13:59:45-07:00

The .Site.Author method and configuration key were deprecated in Hugo v0.124.0 and will be removed in a future release. Use a site parameter or an “authors” taxonomy instead.


The only thing that has been implemented is .Site.Author (singular).

In config.toml, you can not do this:

author = "John Doe"

Instead, do this:

[author]
name = "John Doe"
location = "San Francisco"

The key names (name and location in the example above) are irrelevant. Create your own as needed. Then access these values from a template:

{{ .Site.Author.name }}
{{ .Site.Author.location }}

You can also define many authors in config.toml:

[author]
  [author.john_doe]
    name = "John Doe"
    location = "San Francisco"
  [author.jane_smith]
    name = "Jane Smith"
    location = "New York"

Then access these values from a template:

{{ .Site.Author.john_doe.name }}
{{ .Site.Author.john_doe.location }}
{{ .Site.Author.jane_smith.name }}
{{ .Site.Author.jane_smith.location }}

So then in content you could do something like:

+++
title = "Test"
date = 2021-03-17T07:15:35-07:00
draft = false
author = "john_doe"
+++

Then access the details from a template:

{{ index .Site.Author .Params.author "name" }}
{{ index .Site.Author .Params.author "location" }}
8 Likes