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?
hreflang
attribute should not necessarily be the same format as Craft'slocale
values. Depending on your locales, you may need to translate them into their ISO equivalents for language and country. For exampleen_ca
would becomeen-CA
.