Add language switcher and language detection

This commit is contained in:
2026-08-11 12:25:14 +02:00
parent 3e7c831dac
commit df489c6c79
11 changed files with 526 additions and 384 deletions
+13 -11
View File
@@ -52,6 +52,19 @@
<!-- Canonical URL -->
<link rel="canonical" href="{{ .Permalink }}">
<!-- Alternate language versions of this page -->
{{ if hugo.IsMultilingual }}
{{ range .AllTranslations }}
<link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ .Permalink }}">
{{ end }}
{{ with hugo.Sites.Default.Home }}
<link rel="alternate" hreflang="x-default" href="{{ .Permalink }}">
{{ end }}
{{ end }}
<!-- Language preference / browser language detection (must run before paint) -->
{{ partial "language-detection" . }}
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
@@ -91,17 +104,6 @@
<!-- Footer -->
{{ partial "footer" . }}
<!-- Language Preference Script -->
{{ if hugo.IsMultilingual }}
{{ if .Site.Params.visitorapi_pid }}
<script>
// Inject VisitorAPI project ID from Hugo config
window.HUGO_VISITOR_API_PID = "{{ .Site.Params.visitorapi_pid }}";
</script>
{{ end }}
<script src="{{ "js/language-preference.js" | relURL }}"></script>
{{ end }}
<!-- Mobile Menu Script -->
<script>
const mobileMenuButton = document.getElementById('mobile-menu-button');