Skip to content
This repository was archived by the owner on Dec 20, 2021. It is now read-only.
This repository was archived by the owner on Dec 20, 2021. It is now read-only.

[FEATURE] Generate Hreflang Tags #66

@wblondel

Description

@wblondel

Describe the feature you want

Hello,

For SEO purposes, it would be great to have the hreflang tags generated when a page is translated.

For instance:

<link rel="alternate" href="http://example.com" hreflang="es-es" />
<link rel="alternate" href="http://example.com/fr/" hreflang="fr-fr" />
<link rel="alternate" href="http://example.com/pt/" hreflang="pt-pt" />

Temporarily, I added this snippet in the layouts\partials\head\link.html theme's file, and it seems to do the job:

{{ if .IsTranslated }}
  {{ range .AllTranslations }}
    <link rel="alternate" href="{{ .Permalink }}" hreflang="{{ .Language.Lang }}" />
  {{ end }}
{{ end }}

Useful reference

https://yoast.com/hreflang-ultimate-guide/

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions