templates/app/partials/_canonicals.html.twig line 1

Open in your IDE?
  1. {# Adds canonical for the current page, check if a document property is set named canonical, if not use url of document
  2. Add alternate links for current page as well as for all the possible translations that are set in pimcore.
  3. as the language en-gb is both a audience page as well as the default we add the x-default tag on top of the alternate hreflang=lang #}
  4. <link rel="canonical" href="{{ (document.getProperty('canonical').url ?? document.url) | trimUrl }}"/>
  5. {% if page.lang ?? app.request.locale == "en-gb" %}
  6.     <link rel="alternate" href="{{ document.url | trimUrl }}" hreflang="x-default"/>
  7. {% endif %}
  8. <link rel="alternate" href="{{ document.url | trimUrl }}" hreflang="{{ (page.lang ?? app.request.locale) | replace({'en-gb': 'en'}) }}"/>
  9. <!-- get_rel_alternate() -->
  10. {% for lang, url in get_rel_alternate(document) %}
  11.     {% if lang == "en-gb" %}
  12.         <link rel="alternate" href="{{ url | trimUrl }}" hreflang="x-default"/>
  13.     {% endif %}
  14.     <link rel="alternate" href="{{ url | trimUrl }}" hreflang="{{ lang | replace({'en-gb': 'en'})  }}"/>
  15. {% endfor %}