Skip to content

Commit

Permalink
fix: Missing reciprocal hreflang (no return-tag)
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipe Carneiro committed Oct 16, 2024
1 parent bcb675e commit 7fa8fe5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions layouts/partials/head/seo.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,20 @@
<!-- canonical tag -->
<link rel="canonical" href="{{ .Permalink | safeURL }}">

<!-- Self-referential and X-default hreflang tags -->
<link rel="alternate" hreflang="{{ .Language.LanguageCode | default site.Language.LanguageCode }}" href="{{ .Permalink | safeURL }}">
<!-- Self-referential hreflang attributes -->
<link rel="alternate" hreflang="{{ .Language.LanguageCode | default $.Sites.First.Language.LanguageCode }}" href="{{ .Permalink | safeURL }}">
<!-- Translated pages hreflang tags -->
{{ if .IsTranslated -}}
{{ range .Translations -}}
<link rel="alternate" hreflang="{{ .Language.LanguageCode }}" href="{{ .Permalink | safeURL }}">
{{ end -}}
{{ end -}}
<!-- X-default hreflang tag -->
{{ range .AllTranslations -}}
{{ if eq .Language.LanguageCode $.Sites.First.Language.LanguageCode -}}
<link rel="alternate" hreflang="x-default" href="{{ .Permalink | safeURL }}">
{{ end -}}
{{ end -}}

{{ range .AlternativeOutputFormats -}}
<link rel="{{ .Rel }}" {{ printf "type=%q" .MediaType.Type | safeHTMLAttr }} href="{{ .Permalink | safeURL }}">
Expand Down

0 comments on commit 7fa8fe5

Please sign in to comment.