templates/pages/sitemap.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"
  3.         xmlns:xhtml="http://www.w3.org/1999/xhtml"
  4.         xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
  5.         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6.         xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
  7.     {# ciclo su tutti gli URL #}
  8.     {% for url in urls %}
  9.         <url>
  10.             {# aggiungo l'hostname solo se non presente #}
  11.             <loc>
  12.                 {% if url.loc|replace({hostname:''}) == url.loc %}
  13.                     {{ hostname }}{{ url.loc }}
  14.                 {% else %}
  15.                     {{ url.loc }}
  16.                 {% endif %}
  17.             </loc>
  18.             {# aggiungo tutti gli attributi presenti #}
  19.             {% if url.lastmod is defined %}
  20.                 <lastmod>{{url.lastmod}}</lastmod>
  21.             {% endif %}
  22.             {% if url.changefreq is defined %}
  23.                 <changefreq>{{url.changefreq}}</changefreq>
  24.             {% endif %}
  25.             {% if url.priority is defined %}
  26.                 <priority>{{url.priority}}</priority>
  27.             {% endif %}
  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>