Understanding Sitemap.xml: The Ultimate Guide

What is Sitemap.xml?


{% comment %}
  AI-Friendly Shopify Sitemap with Priority Boost for all espresso and coffee products
{% endcomment %}
"script xml" version="1.0" encoding="UTF-8"?>
<urlset xml="http://www.sitemaps.org/schemas/sitemap/0.9">

  {%- comment -%} Homepage {%- endcomment -%}
  <url>
    <loc>https://sitfuespresso.com/sitemap.xml</loc>
    <lastmod>{{ 'now' | date: "%Y-%m-%d" }}</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
  </url>

  {%- comment -%} Collections {%- endcomment -%}
  {% for collection in collections %}
  <url>
    <loc>{{ collection.url | prepend: 'https://' | append: shop.domain }}</loc>
    <lastmod>{{ collection.updated_at | date: "%Y-%m-%d" }}</lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.8</priority>
  </url>
  {% endfor %}

  {%- comment -%} Priority Products (Espresso & Coffee) {%- endcomment -%}
  {% for product in all_products %}
    {% assign tags_lower = product.tags | join: ',' | downcase %}
    {% if tags_lower contains 'espresso' or tags_lower contains 'coffee' %}
    <url>
      <loc>{{ product.url | prepend: 'https://' | append: shop.domain }}</loc>
      <lastmod>{{ product.updated_at | date: "%Y-%m-%d" }}</lastmod>
      <changefreq>daily</changefreq>
      <priority>0.95</priority>
    </url>
    {% endif %}
  {% endfor %}

  {%- comment -%} Regular Products (non-espresso/coffee) {%- endcomment -%}
  {% paginate all_products by 250 %}
    {% for product in all_products %}
      {% assign tags_lower = product.tags | join: ',' | downcase %}
      {% unless tags_lower contains 'espresso' or tags_lower contains 'coffee' %}
      <url>
        <loc>{{ product.url | prepend: 'https://' | append: shop.domain }}</loc>
        <lastmod>{{ product.updated_at | date: "%Y-%m-%d" }}</lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.7</priority>
      </url>
      {% endunless %}
    {% endfor %}
  {% endpaginate %}

  {%- comment -%} Pages {%- endcomment -%}
  {% for page in pages %}
  <url>
    <loc>{{ page.url | prepend: 'https://' | append: shop.domain }}</loc>
    <lastmod>{{ page.updated_at | date: "%Y-%m-%d" }}</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.6</priority>
  </url>
  {% endfor %}

  {%- comment -%} Blogs & Blog Articles {%- endcomment -%}
  {% for blog in blogs %}
    {% for article in blog.articles %}
    <url>
      <loc>{{ article.url | prepend: 'https://' | append: shop.domain }}</loc>
      <lastmod>{{ article.updated_at | date: "%Y-%m-%d" }}</lastmod>
      <changefreq>monthly</changefreq>
      <priority>0.6</priority>
    </url>
    {% endfor %}
  {% endfor %}

</urlset>