Web development

Create a small XML sitemap

List preferred public URLs in an XML sitemap to help crawlers discover them. Include an accurate modification date only when it represents a meaningful change to that page.

Worked example

Worked reference example

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url><loc>https://example.com/articles/</loc></url>
  <url><loc>https://example.com/articles/reading-json/</loc><lastmod>2026-11-23</lastmod></url>
</urlset>

How it works

Each url element contains a fully qualified location. The namespace identifies the sitemap format. Escaping rules still apply inside XML, so a query-string ampersand must be encoded rather than inserted as a raw character.

Limits and mistakes

A sitemap does not guarantee crawling, indexing, or traffic. Avoid listing redirects, private pages, or nonexistent paths. Updating every lastmod value on every build makes the dates less meaningful and can undermine the signal.

Check the result

Parse the file as XML and request every listed URL. Confirm sitemap addresses agree with canonical links and that newly published pages are linked from ordinary HTML navigation too.

Sources

Reference documentation for the behavior used in this guide: