uPagge / uBlogger

A template designed with your readers in mind :heart:
https://ublogger.netlify.app
MIT License
250 stars 101 forks source link

[FEATURE] Generate Hreflang Tags #66

Closed wblondel closed 3 years ago

wblondel commented 3 years ago

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/

uPagge commented 3 years ago

Great idea, I agree. I will do it in the near future

uPagge commented 3 years ago

I will probably transfer it to the discussion, since this is not a bug.

Please next time with ideas there))