.Site.Author deprecated question (and custom RSS)

I recently had a Hugo build fail because of the .Site.Author being deprecated. I tried reading through other posts, but am still having issues.

I believe I updated my now “hugo.toml” to be correct:

[author]
  name = "Ben W. Fey"
  email = "[email address here]"

But my build just failed. I also have a custom RSS feed and am wondering how to implement the Author update there as it appears my Author name is not showing up in the RSS (and potentially has never worked). I do not have individual authors on individual posts, but have only listed one author in the hugo.toml file.

My RSS template: rss.xml

{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- $pages = (where $pages ".Params.norss" "!=" "true") -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>{{ if eq  .Title  .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
    <link>{{ .Permalink }}</link>
    <description>Recent content {{ if ne  .Title  .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
    <generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
    <language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
    <managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
    <webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
    <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
    <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
    {{- with .OutputFormats.Get "RSS" -}}
    {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
    {{- end -}}
    {{ range $pages }}
    <item>
      <title>{{ .Title }}</title>
      <link>{{ .Permalink }}</link>
      <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
      {{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
      <guid>{{ .Permalink }}</guid>
      {{- $content := replaceRE "a href=\"(#.*?)\"" (printf "%s%s%s" "a href=\"" .Permalink "$1\"") .Content -}}
      {{- $content := replaceRE "a href=\"(.*?.jpg)\"" (printf "%s%s%s" "a href=\"" .Permalink "$1\"") $content -}}
      {{- $content := replaceRE "a href=\"(.*?.pdf)\"" (printf "%s%s%s" "a href=\"" .Permalink "$1\"") $content -}}
	  {{- $content = replaceRE "img src=\"(.*?)\"" (printf "%s%s%s" "img src=\"" .Permalink "$1\"") $content -}}
	  <description>
	  {{ $content | html }}
	  {{ if eq .Type "photos" }}
	  {{ range .Resources }}
        {{ printf "%s%s%s" "<p><img src=\"" .Permalink "\"></p>" }}   
	  {{ end }}
	  {{ end }}
	  </description>
    </item>
    {{ end }}
  </channel>
</rss>

Just move the author dict to the Params section in your config.yaml. :)) (and then refer via Params.author.<key_name>)

Hint: Mind your context. You use .Site… and next $.Site…

The . Refers to the current page in the loop
The $ to the initial passed page…

Not a problem in your current code but may cause hazards when you reorganize

I personally use the global site function site | Hugo as by the docs recommendation.

To simplify your templates, use the global site function regardless of whether the Site object is in context.

More info on that author thing is here:

thank you @irkode and @essentialblend!

I was able to update my hugo.toml to:

  [params.author]
     name = "Ben W. Fey"

and the RSS to:

{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- $pages = (where $pages ".Params.norss" "!=" "true") -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>{{ if eq  .Title  .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
    <link>{{ .Permalink }}</link>
    <description>Recent content {{ if ne  .Title  .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
    <generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
    <language>{{.}}</language>{{end}}
    <managingEditor>{{ with $.Site.Params.author.name }}{{.}}</managingEditor>{{end}}
    <webMaster>{{ with $.Site.Params.author.name }}{{.}}</webMaster>{{end}}{{ with .Site.Copyright }}
    <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
    <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
    {{- with .OutputFormats.Get "RSS" -}}
    {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
    {{- end -}}
    {{ range $pages }}
    <item>
      <title>{{ .Title }}</title>
      <link>{{ .Permalink }}</link>
      <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
      <author>{{ with $.Site.Params.author.name }}{{.}}</author>{{end}}
      <guid>{{ .Permalink }}</guid>
      {{- $content := replaceRE "a href=\"(#.*?)\"" (printf "%s%s%s" "a href=\"" .Permalink "$1\"") .Content -}}
      {{- $content := replaceRE "a href=\"(.*?.jpg)\"" (printf "%s%s%s" "a href=\"" .Permalink "$1\"") $content -}}
      {{- $content := replaceRE "a href=\"(.*?.pdf)\"" (printf "%s%s%s" "a href=\"" .Permalink "$1\"") $content -}}
	  {{- $content = replaceRE "img src=\"(.*?)\"" (printf "%s%s%s" "img src=\"" .Permalink "$1\"") $content -}}
	  <description>
	  {{ $content | html }}
	  {{ if eq .Type "photos" }}
	  {{ range .Resources }}
        {{ printf "%s%s%s" "<p><img src=\"" .Permalink "\"></p>" }}   
	  {{ end }}
	  {{ end }}
	  </description>
    </item>
    {{ end }}
  </channel>
</rss>

With those changes, my site is building again. In making this update, I decided to remove my email from the RSS, so I simplified it a bit.

I will have to look more into the site vs .Site vs $.Site.