config: adjust to changes in Hugo 0.120 #693

This commit is contained in:
Sören Weber 2023-10-20 19:50:14 +02:00
parent bb76d25145
commit 7665a4aeca
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
5 changed files with 77 additions and 18 deletions

View file

@ -212,7 +212,6 @@ title = "Hugo Relearn Theme"
images = ["images/hero.png"]
editURL = "https://github.com/McShelby/hugo-theme-relearn/edit/main/exampleSite/content/"
description = "Documentation for Hugo Relearn Theme"
author = "Sören Weber"
showVisitedLinks = true
collapsibleMenu = true
disableBreadcrumb = false
@ -233,6 +232,8 @@ title = "Hugo Relearn Theme"
# security reasons
mermaidInitialize = "{ \"securityLevel\": \"loose\" }"
mermaidZoom = true
[params.author]
name = "Sören Weber"
[params.siteparam.test]
text = "A **nested** parameter <b>with</b> formatting"
[params.imageEffects]

View file

@ -1,8 +1,30 @@
{{- partialCached "page-meta.hugo" . .RelPermalink }}
{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}}
{{- $authorEmail := "" }}
{{- if and .Site.Params.author (reflect.IsMap .Site.Params.author) .Site.Params.author.email }}
{{- $authorEmail = .Site.Params.author.email }}
{{- else }}
{{- with .Site.Author.email }}
{{- $authorEmail = . }}
{{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }}
{{- end }}
{{- end }}
{{- /* Deprecate site.Author.name in favor of site.Params.author.name */}}
{{- $authorName := "" }}
{{- if and .Site.Params.author (reflect.IsMap .Site.Params.author) .Site.Params.author.name }}
{{- $authorName = .Site.Params.author.name }}
{{- else }}
{{- with .Site.Author.name }}
{{- $authorName = . }}
{{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }}
{{- end }}
{{- end }}
{{- $pages := .Page.Pages }}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 0 -}}
{{- $pages = $pages | first $limit -}}
{{- $limit := .Site.Config.Services.RSS.Limit }}
{{- if ge $limit 0 }}
{{- $pages = $pages | first $limit }}
{{- end }}
{{- $page := . }}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
@ -12,12 +34,12 @@
<link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</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 }}
<language>{{ . }}</language>{{end}}{{ with $authorEmail }}
<managingEditor>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ 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" -}}
{{- with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" ( partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true)) .MediaType | safeHTML }}
{{- end -}}
{{- range $pages }}
@ -27,9 +49,7 @@
<title>{{ .Title }}</title>
<link>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</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 }}
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
<guid>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</guid>
<description>{{ .Summary | html }}</description>
</item>

View file

@ -14,8 +14,22 @@
<meta name="robots" content="noindex, nofollow, noarchive, noimageindex">
{{- end }}
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}">
{{- with .Site.Params.author }}
<meta name="author" content="{{ . }}">
{{- $authorName := "" }}
{{- if .Site.Params.author }}
{{- if reflect.IsMap .Site.Params.author }}
{{- with .Site.Params.author.name }}
{{- $authorName = . }}
{{- end }}
{{- else }}
{{- warnf "According to Hugo 0.120.0 the author key in params configuration should now be a map and contain of name and email fields." }}
{{- $authorName = .Site.Params.author }}
{{- end }}
{{- else }}
{{- with .Site.Author.name }}
{{- $authorName = . }}
{{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }}
{{- end }}
{{- end }}
<meta name="author" content="{{ $authorName }}">
{{- partial "twitter_cards.html" . }}
{{- partial "opengraph.html" . }}

View file

@ -107,7 +107,19 @@
{{- end }}
{{- end }}
{{- end }}
{{- /* Deprecate site.Social.facebook_admin in favor of site.Params.social.facebook_admin */}}
{{- $facebookAdmin := "" }}
{{- with site.Params.social.facebook_admin }}
{{- $facebookAdmin = . }}
{{- else }}
{{- with site.Social.facebook_admin }}
{{- $facebookAdmin = . }}
{{- warnf "The social key in site configuration is deprecated. Use params.social.facebook_admin instead." }}
{{- end }}
{{- end }}
{{- /* Facebook Page Admin ID for Domain Insights */}}
{{- with .Site.Social.facebook_admin }}
{{- with $facebookAdmin }}
<meta property="fb:admins" content="{{ . }}">
{{- end }}

View file

@ -43,6 +43,18 @@
{{- end }}
<meta name="twitter:title" content="{{ $title }}">
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
{{- with .Site.Social.twitter }}
{{- /* Deprecate site.Social.twitter in favor of site.Params.social.twitter */}}
{{- $twitterSite := "" }}
{{- with site.Params.social.twitter }}
{{- $twitterSite = . }}
{{- else }}
{{- with site.Social.twitter }}
{{- $twitterSite = . }}
{{- warnf "The social key in site configuration is deprecated. Use params.social.twitter instead." }}
{{- end }}
{{- end }}
{{- with $twitterSite }}
<meta name="twitter:site" content="@{{ . }}">
{{- end }}