Just adding hreflang tags to the head on all pages of my multi-locale site...

{% for locale in craft.i18n.getSiteLocales() %}
    <link rel="alternate" href="{{ entry.url }}" hreflang="{{ locale }}">
{% endfor %}

Nearly there, but obviously this outputs my list of locales with the entry url for the current locale only. What I need is to output the entry url for each locale. Anyone done this before?

  • The accepted answer works - however, beware that the hreflang attribute should not necessarily be the same format as Craft's locale values. Depending on your locales, you may need to translate them into their ISO equivalents for language and country. For example en_ca would become en-CA. Apr 28, 2017 at 15:27

1 Answer 1


Have you tried using {{ craft.entries.id(entry.id).locale(locale.id).first().url }} inside the for loop you have made?

  • Great, glad it sorted it for you, see you at the next craft meet up :P Mar 30, 2017 at 8:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.