HUGO

.Param "name.subname" is not checking site config if not present in post frontmatter

What version of Hugo are you using (hugo version)?

$ hugo v0.88.1-5BC54738+extended linux/amd64 BuildDate=2021-09-04T09:39:19Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes

Setup:

  1. In config.toml
[author]
  name = "Jane Doe"
  email = "jane@example.com"
  homepage = "https://example.com"
  avatar = "https://example.com/avatar.webp"
  1. Code:
<author>
  <name>{{ with .Param "author.name" }}{{ . }}{{ end }}</name>
  {{ with .Param "author.email" }}<email>{{ . }}</email>{{ end }}
  {{ with .Param "author.homepage" }}<uri>{{ . }}</uri>{{ end }}
</author>

Or:

<p>
  Name: {{ with $.Param "author.name" }}{{ . }}{{ end }}
  {{ with $.Param "author.email" }}Email: {{ . }}{{ end }}
  {{ with $.Param "author.homepage" }}Homepage: {{ . }}{{ end }}
</p>

If I understood correctly, .Param will look into a page’s frontmatter first and if it doesn’t find it there, it will check in the site’s config.toml file. But it doesn’t seem to be checking the config.toml file if it is not in a page’s frontmatter.

Did I miss anything or new bug?

You need to define it under config params map:

++[params.author]
  name = "Jane Doe"
  email = "jane@example.com"
  homepage = "https://example.com"
  avatar = "https://example.com/avatar.webp"

Yes, it’s little bit confusing because Hugo alse reserved key name author to supply .Site.Author variable.

Ahh, yeah it was confusing.

I finally understood what’s happening. :slight_smile: Thanks a bunch!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.