Add language switcher and language detection
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user