From dd8292accaac3df9d2cb6dc8e0150e158f9ca7b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 11 Dec 2022 23:18:59 +0100 Subject: [PATCH] theme: fix alias for home page if defaultContentLanguageInSubdir=true #414 --- layouts/alias.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/layouts/alias.html b/layouts/alias.html index 61210feb92..e63cc4bdea 100644 --- a/layouts/alias.html +++ b/layouts/alias.html @@ -2,7 +2,19 @@ {{- $url := replace (replace .Permalink site.BaseURL "/") "//" "/" }} - {{- $url = partial "relLangPrettyUglyURL.hugo" (dict "link" $url) }} + {{- with site.Home.GetPage $url }} + {{- $c := "" }}{{/* if defaultContentLanguageInSubdir=false we are ending here for home page of the default language */}} + {{- $url = partial "relLangPrettyUglyURL.hugo" (dict "to" .) }} + {{- else }} + {{- $url_alt := replaceRE "^/[^/]*(/.*)" "${1}" $url }} + {{- with site.Home.GetPage $url_alt }} + {{- $c := "" }}{{/* if defaultContentLanguageInSubdir=true we are ending here for home page */}} + {{- $url = partial "relLangPrettyUglyURL.hugo" (dict "to" .) }} + {{- else }} + {{- $c := "" }}{{/* for regular aliases we are ending here with no original page found */}} + {{- $url = partial "relLangPrettyUglyURL.hugo" (dict "link" $url) }} + {{- end }} + {{- end }}