templates/vitrine/components/canonical.html.twig line 1

Open in your IDE?
  1. {% if page is not empty %}
  2. {% set esPath = getPathPageHasLanguages(page.id,"es") %}
  3. {% set enPath = getPathPageHasLanguages(page.id,"en") %}
  4. {% set frPath = getPathPageHasLanguages(page.id,"fr") %}
  5. {% set dePath = getPathPageHasLanguages(page.id,"de") %}
  6. {% set nlPath = getPathPageHasLanguages(page.id,"nl") %}
  7. {% if enPath == "#" %}
  8. {% if page.name == "homepage" %}
  9. {% set enPath = "/" %}
  10. {% elseif page.name == "press" %}
  11. {% set enPath = "/press" %}
  12. {% elseif page.name == "faq" %}
  13. {% set enPath = "/faq" %}
  14. {% elseif page.name == "articles" %}
  15. {% set enPath = "/articles" %}
  16. {% endif %}
  17. {% endif %}
  18. {% set defaultPath = enPath %}
  19. {% if app.request.locale == "fr" %}
  20. {% set defaultPath = frPath %}
  21. {% elseif app.request.locale == "de" %}
  22. {% set defaultPath = dePath %}
  23. {% elseif app.request.locale == "nl" %}
  24. {% set defaultPath = nlPath %}
  25. {% elseif app.request.locale == "es" %}
  26. {% set defaultPath = esPath %}
  27. {% endif %}
  28. {% set domainDefault = domain ~ defaultPath %}
  29. {% set domainFrDefault = domain ~ frPath %}
  30. {% set domainEsDefault = domain ~ esPath %}
  31. {% set domainEnDefault = domain ~ enPath %}
  32. {% set domainDeDefault = domain ~ dePath %}
  33. {% set domainNlDefault = domain ~ nlPath %}
  34. {% if app.request.locale == "en" %}
  35. <link rel="canonical" href="{{ domainEnDefault }}" />
  36. {% endif %}
  37. {% if app.request.locale == "fr" %}
  38. <link rel="canonical" href="{{ domainFrDefault }}" />
  39. {% endif %}
  40. {% if app.request.locale == "es" %}
  41. <link rel="canonical" href="{{ domainEsDefault }}" />
  42. {% endif %}
  43. {% if app.request.locale == "nl" %}
  44. <link rel="canonical" href="{{ domainNlDefault }}" />
  45. {% endif %}
  46. {% if app.request.locale == "de" %}
  47. <link rel="canonical" href="{{ domainDeDefault }}" />
  48. {% endif %}
  49. {% if defaultPath == "//" or defaultPath == "/fr//" or defaultPath == "/de//" or defaultPath == "/es//" or defaultPath == "/nl//" %}{% set domainDefault = domain %}{% endif %}
  50. {% if enPath == "//" %}{% set domainEnDefault = domain %}{% endif %}
  51. {% if frPath == "/fr//" %}{% set domainFrDefault = domain ~ '/fr' %}{% endif %}
  52. {% if dePath == "/de//" %}{% set domainDeDefault = domain ~ '/de' %}{% endif %}
  53. {% if esPath == "/es//" %}{% set domainEsDefault = domain ~ '/es' %}{% endif %}
  54. {% if nlPath == "/nl//" %}{% set domainNlDefault = domain ~ '/nl' %}{% endif %}
  55. {% if app.request.locale == "en" %}{% set domainEnDefault = app.request.schemeAndHttpHost ~ app.request.basePath ~ app.request.pathInfo %}{% endif %}
  56. <link rel="alternate" hreflang="x-default" href="{{ domainEnDefault }}" />
  57. <link rel="alternate" hreflang="en" href="{{ domainEnDefault }}" />
  58. {% if app.request.locale == "fr" %}{% set domainFrDefault = app.request.schemeAndHttpHost ~ app.request.basePath ~ app.request.pathInfo %}{% endif %}
  59. <link rel="alternate" hreflang="fr" href="{{ domainFrDefault }}" />
  60. {% if app.request.locale == "de" %}{% set domainDeDefault = app.request.schemeAndHttpHost ~ app.request.basePath ~ app.request.pathInfo %}{% endif %}
  61. <link rel="alternate" hreflang="de" href="{{ domainDeDefault }}" />
  62. {% if app.request.locale == "es" %}{% set domainEsDefault = app.request.schemeAndHttpHost ~ app.request.basePath ~ app.request.pathInfo %}{% endif %}
  63. <link rel="alternate" hreflang="es" href="{{ domainEsDefault }}" />
  64. {% if app.request.locale == "nl" %}{% set domainNlDefault = app.request.schemeAndHttpHost ~ app.request.basePath ~ app.request.pathInfo %}{% endif %}
  65. <link rel="alternate" hreflang="nl" href="{{ domainNlDefault }}" />
  66. {% endif %}