doc/dev/plugins/langswitcher/templates/partials/langswitcher.hreflang.html.twig

9 lines
435 B
Twig

{% set langobj = grav['language'] %}
{% for key in langswitcher.languages %}
{% if key == langswitcher.current %}
{% set lang_url = page.url is same as('/') ? '' : page.url %}
{% else %}
{% set lang_url = (langobj.getLanguageURLPrefix(key) ~ langswitcher.page_route ~ page.urlExtension ?: '')|rtrim('/') %}
{% endif %}
<link rel="alternate" hreflang="{{ key }}" href="{{ uri.base ~ lang_url ~ uri.params }}" />
{% endfor %}