Shopify Create Sitemap Page

Mohit Mehta
2 min readMar 5, 2019

The Sitemaps informs search engines about URLs on a website that are available for crawling. So it’s very important for better SEO. Foe e-commerce sitemap is just a page which has listed all of your products, collections or categories and other pages.

First of all you need to create new template where we will add some lines of code. To create new template follow these steps,

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme where you want to create sitemap, and then click Actions > Edit code.
  3. In the Templates directory, click Add a new template.
  4. Select page from drop-down and named it sitemap as shown below.

Now you can add below code snippet to this template. Make sure you add the code below line ‘{{ page.content }}’.

To list out all products of your Shopify store, first you have to create one new collection. Let’s say that collection ‘all-products’ and below code to newly created template.

To list out all products from collection ‘all-products’,

<div class="parent-container">
<h1>Products:</h1>
<div class="link-container">
{% if collections.all-products.products.size > 0 %}
{% for product in collections.all-products.products %}
<a class="sitemap_link" href="{{ product.url }}">{{ product.title | escape }}</a>
{% endfor %}
{% endif %}
</div>
</div>

To list out all collections,

<div class="parent-container">
<h1>Collections:</h1>
<div class="link-container">
{% for product in collections %}
{% if product.handle != 'all-products' %}
<a class="sitemap_link" href="{{ product.url | within: collection }}">{{ product.title }}</a>&nbsp;
{% endif %}
{% endfor %}
</div>
</div>

Here I have not included ‘all-products’ collection.

To list our all pages,

<div class="parent-container">
<h1>Pages:</h1>
<div class="link-container">
{% for link in linklists.sitemap-menu.links %}
<a class="sitemap_link" href="{{ link.url }}">{{ link.title }} </a>
{% endfor %}
</div>
</div>

Now our template is ready. So let’s create a new page. To create new page follow these steps,

  1. From your Shopify admin, go to Online Store > Pages and click on Add Page.
  2. Give the page title as Sitemap and leave content empty.
  3. From Template section in right side, select page.sitemap.

Now our Sitemap page is completed and ready to test. This is how we can list out all products, collections and pages of Shopify in one page.

--

--