From 143b09b8006e0c7ed9eeda31868e45ffd29c5d5a Mon Sep 17 00:00:00 2001 From: Chen Xianmin Date: Sun, 3 Nov 2024 20:26:17 +0800 Subject: [PATCH] fix: seo Add self-referencing hreflang --- layouts/partials/head.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index b0c86ce8..6c24fc6c 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -10,8 +10,14 @@ {{- end -}} -{{ range .Translations }} - +{{/* Only add hreflang tags if site is multilingual */}} +{{ if hugo.IsMultilingual }} + {{/* Add translations */}} + {{ range .Translations }} + + {{ end }} + {{/* Add self-referencing hreflang */}} + {{ end }}