Question about hreflang attribute

Run hugo mod vendor and then search the code base for .AllTranslations.

You’ll find this file:
_vendor/github.com/gethugothemes/hugo-modules/seo-tools/basic-seo/layouts/partials/basic-seo.html

With this code:

<!-- multilingual SEO optimizations -->
{{ if .IsTranslated }}
  {{ range .AllTranslations }}
    <link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}" />
  {{ end }}
  <link rel="alternate" hreflang="x-default" href="{{ .Permalink }}" />
{{ end }}

Just override that partial (create layouts/partials/basic-seo.html), and remove the section above.

When you’re done, remove the _vendor directory.

2 Likes