theme: fix alias for home page if defaultContentLanguageInSubdir=true #414

This commit is contained in:
Sören Weber 2022-12-11 23:18:59 +01:00
parent 16f3f0e73d
commit dd8292acca
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -2,7 +2,19 @@
<html>
<head>
{{- $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 }}
<meta charset="utf-8">
<meta name="robots" content="noindex">
<meta http-equiv="refresh" content="0; url={{ $url }}">