fix: migrate deprecated Hugo v0.158.0 language API

Replace deprecated config keys and template methods per Hugo v0.158.0:

Config (10 files):
- languageCode → locale
- languageName → label

Templates:
- site.LanguageCode → site.Language.Locale (baseof.html, head.html, schema.html x2)
- site.Language.Lang → site.Language.Name (single.html)
- .Lang → .Language.Name (likes.html, views.html)

Ref: https://discourse.gohugo.io/t/deprecations-in-v0-158-0/56869
This commit is contained in:
Eric Gusmao
2026-03-25 11:02:54 -03:00
parent b0c563bc15
commit 7c127074f9
16 changed files with 27 additions and 27 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
disabled = false
languageCode = "en"
languageName = "English"
locale = "en"
label = "English"
weight = 1
title = "Blowfish"
@@ -1,5 +1,5 @@
languageCode = "de"
languageName = "Deutsch"
locale = "de"
label = "Deutsch"
weight = 3
title = "Blowfish"
@@ -1,5 +1,5 @@
languageCode = "en"
languageName = "English"
locale = "en"
label = "English"
weight = 1
title = "Blowfish"
@@ -1,5 +1,5 @@
languageCode = "es"
languageName = "Español"
locale = "es"
label = "Español"
weight = 6
title = "Blowfish"
@@ -1,5 +1,5 @@
languageCode = "fr"
languageName = "Français"
locale = "fr"
label = "Français"
weight = 2
title = "Blowfish"
@@ -1,5 +1,5 @@
languageCode = "it"
languageName = "Italiano"
locale = "it"
label = "Italiano"
weight = 4
title = "Blowfish"
@@ -1,5 +1,5 @@
languageCode = "ja"
languageName = "日本語"
locale = "ja"
label = "日本語"
weight = 8
title = "Blowfish"
@@ -1,5 +1,5 @@
languageCode = "pt-br"
languageName = "Português (Brasil)"
locale = "pt-br"
label = "Português (Brasil)"
weight = 6
title = "Blowfish"
@@ -1,5 +1,5 @@
languageCode = "pt-pt"
languageName = "Português (Portugal)"
locale = "pt-pt"
label = "Português (Portugal)"
weight = 5
title = "Blowfish"
@@ -1,5 +1,5 @@
languageCode = "zh-cn"
languageName = "简体中文"
locale = "zh-cn"
label = "简体中文"
weight = 9
title = "Blowfish"
+1 -1
View File
@@ -1,6 +1,6 @@
<!doctype html>
<html
lang="{{ with site.Params.isoCode | default (site.LanguageCode | default `en`) }}{{- . -}}{{ end }}"
lang="{{ with site.Params.isoCode | default (site.Language.Locale | default `en`) }}{{- . -}}{{ end }}"
dir="{{ cond (site.Params.rtl | default false) `rtl` `ltr` }}"
class="scroll-smooth"
data-default-appearance="{{ site.Params.defaultAppearance | default `light` }}"
+1 -1
View File
@@ -123,7 +123,7 @@
{{ end }}
{{ $finalLink := $taxonomyLink }}
{{ $currentLang := site.Language.Lang }}
{{ $currentLang := site.Language.Name }}
{{ if eq site.LanguagePrefix "" }}
{{ $finalLink = printf "%sauthors/%s/" $baseURL $author }}
{{ else }}
+1 -1
View File
@@ -1,6 +1,6 @@
<head>
<meta charset="utf-8">
{{ with .Site.Language.Params.htmlCode | default .Site.LanguageCode }}
{{ with .Site.Language.Params.htmlCode | default .Site.Language.Locale }}
<meta http-equiv="content-language" content="{{ . }}">
{{ end }}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
+1 -1
View File
@@ -9,7 +9,7 @@
{{ with .File }}
{{ $path := .Path }}
{{ range $translations }}
{{ $lang := print "." .Lang ".md" }}
{{ $lang := print "." .Language.Name ".md" }}
{{ $path = replace $path $lang ".md" }}
{{ end }}
{{ $id = delimit (slice "likes_" $path) "" }}
+1 -1
View File
@@ -9,7 +9,7 @@
{{ with .File }}
{{ $path := .Path }}
{{ range $translations }}
{{ $lang := print "." .Lang ".md" }}
{{ $lang := print "." .Language.Name ".md" }}
{{ $path = replace $path $lang ".md" }}
{{ end }}
{{ $id = delimit (slice "views_" $path) "" }}
+2 -2
View File
@@ -6,7 +6,7 @@
"@id": {{ site.Home.Permalink | safeURL }},
"name": "{{ .Site.Title | safeJS }}",
{{ with .Site.Params.description }}"description": "{{ . | safeJS }}",{{ end }}
{{ with .Site.LanguageCode }}"inLanguage": "{{ . }}",{{ end }}
{{ with .Site.Language.Locale }}"inLanguage": "{{ . }}",{{ end }}
"url": {{ site.Home.Permalink | safeURL }},
{{ with .Site.Params.keywords }}"keywords": {{ . }},{{ end }}
"publisher" : {
@@ -25,7 +25,7 @@
"name": "{{ .Title | safeJS }}",
"headline": "{{ .Title | safeJS }}",
{{ with .Description }}"description": "{{ . | safeJS }}",{{ end }}
{{ with .Site.LanguageCode }}"inLanguage": "{{ . }}",{{ end }}
{{ with .Site.Language.Locale }}"inLanguage": "{{ . }}",{{ end }}
"url" : {{ .Permalink }},
"author" : {
"@type": "Person",