templates/sitemap/index.html.twig line 1

Open in your IDE?
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
  3.     {# On boucle sur les URLs #}
  4.     {% for url in urls %}
  5.         <url>
  6.             {# On vérifie si le nom d'hôte (hostname) est présent dans l'url #}
  7.             {# Si il n'y est pas, on l'ajoute #}
  8.             <loc>
  9.                 {%if url.loc|replace({hostname:''}) == url.loc%}
  10.                     {{hostname}}{{url.loc}}
  11.                 {%else%}
  12.                     {{url.loc}}
  13.                 {%endif%}
  14.             </loc>
  15.             {# Si il y a une date de modification #}
  16.             {% if url.lastmod is defined %}
  17.                 <lastmod>{{url.lastmod}}</lastmod>
  18.             {% endif %}
  19.             {# Si il y a une fréquence de modification #}
  20.             {% if url.changefreq is defined %}
  21.                 <changefreq>{{url.changefreq}}</changefreq>
  22.             {% endif %}
  23.             {# Si il y a une priorité #}
  24.             {% if url.priority is defined %}
  25.                 <priority>{{url.priority}}</priority>
  26.             {% endif %}
  27.             {# Si il y a une image #}
  28.             {% if url.image is defined and url.image is not empty %}
  29.                 <image:image>
  30.                     <image:loc>{%if url.image.loc|replace({hostname:''}) == url.image.loc%}{{hostname}}{{url.image.loc}}{%else%}{{url.image.loc}}{%endif%}</image:loc>
  31.                     <image:title>{{ url.image.title }}</image:title>
  32.                 </image:image>
  33.             {% endif %}
  34.         </url>
  35.     {% endfor %}
  36. </urlset>