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