Skip to content

Commit

Permalink
fix: seo <head> Add self-referencing hreflang
Browse files Browse the repository at this point in the history
  • Loading branch information
xianmin committed Nov 3, 2024
1 parent 1fb65d7 commit 143b09b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
{{- end -}}
</title>

{{ range .Translations }}
<link rel="alternate" hreflang="{{ .Site.LanguageCode }}" href="{{ .Permalink }}" />
{{/* Only add hreflang tags if site is multilingual */}}
{{ if hugo.IsMultilingual }}
{{/* Add translations */}}
{{ range .Translations }}
<link rel="alternate" hreflang="{{ .Site.LanguageCode }}" href="{{ .Permalink }}" />
{{ end }}
{{/* Add self-referencing hreflang */}}
<link rel="alternate" hreflang="{{ .Site.LanguageCode }}" href="{{ .Permalink }}" />
{{ end }}

<meta name="renderer" content="webkit" />
Expand Down

0 comments on commit 143b09b

Please sign in to comment.