From e9f46b1e5a2c41bfe1da702b3823d64fb3d64017 Mon Sep 17 00:00:00 2001 From: Arne Rief Date: Thu, 9 Apr 2026 18:31:14 +0200 Subject: Replaced deprecated language methods & settings from hugo v0.156.0 & v0.158.0 --- hugo.toml | 10 +++++----- layouts/_partials/select-language.html | 32 +++++++++++++++----------------- layouts/baseof.html | 2 +- layouts/rss.xml | 2 +- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/hugo.toml b/hugo.toml index 41d29c0..184ebde 100644 --- a/hugo.toml +++ b/hugo.toml @@ -1,5 +1,5 @@ baseURL = "https://example.org/" -languageCode = "en-US" +locale = "en" title = "Your Website Name" enableRobotsTXT = true # Copy this line to your project's hugo.toml @@ -16,8 +16,8 @@ disableDefaultLanguageRedirect = false [languages] [languages.de] contentDir = "content/de" - languageCode = "de-DE" - languageName = "Deutsch" + locale = "de" + label = "Deutsch" weight = 2 [[languages.de.menus.main]] @@ -41,8 +41,8 @@ disableDefaultLanguageRedirect = false [languages.en] contentDir = "content/en" - languageCode = "en-US" - languageName = "English" + locale = "en" + label = "English" weight = 1 [menus] diff --git a/layouts/_partials/select-language.html b/layouts/_partials/select-language.html index 6efcc61..5cb4a25 100644 --- a/layouts/_partials/select-language.html +++ b/layouts/_partials/select-language.html @@ -1,32 +1,30 @@ {{- /* Selection of available languages. -Dynamically links to corresponding page/post if a translated version exists, otherwise to homepage of that language as fallback. +Dynamically links to corresponding versions of a page/post in other languages if translations exists. -Note: `$activeLang` and `$allTranslationsForPage` are technically unnecessary variables, their values could be called with `$.Lang` and `$.Translations` respectively. -These variables - together with the explicit naming of `.` context variables in other cases - were chosen for better readability and understandability of the code. +Note: `.Site.Language.Name` and `.Site.Language.Locale` are interchangable with Argo's default hugo.toml configuration of `locale = "en"`. +Yet the differentiation is deliberately maintained here in case a user defines their locale to e.g. "en-US"; */ -}} -{{- if gt (len site.Languages) 1 }} -{{- $activeLang := .Lang }} -{{- $allTranslationsForPage := .Translations }} +{{- $pageVersionsList := .Rotate "language" }} +{{- if gt (len $pageVersionsList) 1 }}