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