How do I make an XML sitemap?

An XML sitemap can help inform search engines about pages in your site that are available to crawl and the date they were last modified. We have an example SEO Sitemap   Velocity Format which can be applied to an Index Block configured to index your site.

Here are the steps to create a basic XML sitemap:

  1. Create a Velocity Format containing the following, replacing "https://www.example.com" with the URL of your site and ".html" with the file extension of your pages, if not HTML:

    ## Root domain where website is hosted
    #set ($websiteURL = "https://www.example.com")
    ## Page extension
    #set ($extension = ".html")
    
    #set ($pages = $_XPathTool.selectNodes($contentRoot, "//system-page[is-published][last-published-on]"))
    
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    #foreach ($p in $pages)
    #set ($path = $p.getChild("path").value)
    #set ($last = $p.getChild("last-modified"))
    <url>
    <loc>${websiteURL}${path}${extension}</loc>
    <lastmod>#showDate($last.value, 'yyyy-MM-dd')</lastmod>
    </url>
    #end
    </urlset> #macro (showDate $dateValue $formatString) #if ($dateValue != "") #set ($dateObject = $_DateTool.getDate($dateValue)) #else #set ($dateObject = $_DateTool.getDate()) #end #set ($dateString = $_DateTool.format($formatString, $dateObject)) ${dateString} #end
  2. Create a Template containing a single DEFAULT region:

    <system-region name="DEFAULT"/>
  3. Create an Index Block with the following settings:
    • Index type - "Folder Index"
    • Index folder - Select the base folder of your site.
    • Rendering behavior - "Render normally, starting at the indexed folder"
    • Depth of index - Set as needed to index the pages in your site.
    • Max rendered assets - Set as needed to index the pages in your site.
    • Indexed asset content - Select "Regular Content" and "System Metadata".
    • Indexed asset types - "Pages"
    • Page XML - "Do not render page XML inline"
    • Sort method - URLs can be in any order in a sitemap, so choose the order that works best for you.
  4. Create a Configuration and an Output with the following settings:
    • Type of data - "XML"
    • File extension - ".xml"
    • Template - Choose the Template you created earlier.
    • Check the Publishable setting.
    • Check the Include XML Declaration in Published Files setting.
    • In the Regions area, assign the sitemap Index Block and Format to the DEFAULT region.
  5. Create a Content Type and select the sitemap Configuration and Metadata Set of your choice.
    • A Data Definition/WYSIWYG isn't used for this application.
  6. Create a new page in the base folder of your site using the sitemap Content Type.
Note - Index Blocks won't pick up pages that are non-indexable (have Include when indexing unchecked) or whose folder hierarchy prevents them from being indexed.
Tip - You can add additional url tags to your sitemap such as changefreq or priority by using custom metadata fields in your pages, just make sure that your sitemap Index Block also indexes "User Metadata".