Sitemap Logo Sitemap

Creates a dynamic XML sitemap of your entire site.

This plu­gin is for Craft CMS 2 and has been dis­con­tin­ued. We recom­mend using the SEO plu­gin instead, which works with Craft ver­sions 2 and 3.

Sitemap auto­mat­ic­ally cre­ates a dynam­ic XML sitemap of your entire site and informs search engines exactly which pages on your site are avail­able for crawling.

Craft Sitemap 05

The Sitemap plu­gin allows you to select which sec­tions and cat­egory groups to include in the sitemap and to set the change fre­quency and pri­or­ity of each. If you have the Com­merce plu­gin installed then you can also select product types to include. You can also add indi­vidu­al URL’s to the sitemap and set their preferences.

Note that this plu­gin cre­ates an XML sitemap spe­cific­ally for search engines, and not a HTML sitemap for your front-end site. Find out more about sitemaps at sitemaps​.org.

Ping Search Engines #

You have your sitemap pinged to Google and Bing by click­ing on the Save and Ping” but­ton. This will inform them that your sitemap has changed and that they should recrawl your site.

Google Web­mas­ter Tools #

Ideally you should sub­mit the URL of your sitemap through Google Web­mas­ter Tools. Besides noti­fy­ing Google about your sitemap, this allows you to man­age and also see vari­ous inform­a­tion about your sitemap. Find out more here.

By default your sitemap’s URL will be your site’s root URL fol­lowed by /sitemap.xml, so for example:

Mul­tiple Sitemaps #

If your serv­er is run­ning out of memory due to a large sitemap, you can break it up into smal­ler batches by spe­cify­ing the offset (default is 0) and limit (default is 50,000) para­met­ers in the URL as follows:

You can then cre­ate and sub­mit a sitemaps index file to Google that con­tains mul­tiple sitemap URL’s as follows:

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="">
    {% set offset = 0 %}
    {% set limit = 1000 %}
    {% for i in 0..10 %}
            <loc>{{ url('sitemap.xml') }}?offset={{ offset }}&limit={{ limit }}</loc>
            <lastmod>{{ now.atom }}</lastmod>
        {% set offset = offset + limit %}
    {% endfor %}

Set­tings #

Enable Site Route
Wheth­er to auto­mat­ic­ally route /sitemap.xml to the XML sitemap

Multi Loc­ale Sitemap Enabled
Wheth­er to allow mul­tiple loc­ales to appear in the sitemap


Enable Site Route #

If you choose to dis­able the site route set­ting then Sitemap will not auto­mat­ic­ally route /sitemap.xml to the XML sitemap. Instead, you can fetch the sitemap manu­ally by cre­at­ing a tem­plate on the front-end and adding the fol­low­ing tag:

{{ craft.sitemap.get }}

Hooks #

Sitemap comes with the fol­low­ing hooks that plu­gins can latch onto. Cre­ate the meth­ods in your plugin’s primary class.


Use this hook to add URL’s to the sitemap. This hook must return an array of URL’s format­ted as follows:

public function addSitemapUrls()
    $urls = array(
            'url' => UrlHelper::getSiteUrl('custom-url-01'),
            'lastmodDate' => new DateTime,
            'changeFrequency' => 'weekly',
            'priority' => 0.5,
            'url' => UrlHelper::getSiteUrl('custom-url-02'),
            'lastmodDate' => new DateTime,
            'changeFrequency' => 'weekly',
            'priority' => 0.5,

    return $urls;

Troubleshoot­ing #

The fol­low­ing error can appear if anoth­er plu­gin by the same name Sitemap” was pre­vi­ously installed:

Template Error: Variable "sections" does not exist.

To fix this, ensure that you have uploaded the cor­rect plu­gin files and clear the cache in the Craft con­trol pan­el under Set­tings”.