How to Create a Sitemap for a Website

Create an XML sitemap by hand or with your framework, put it where search engines expect it, and tell Google it exists.

A sitemap is an XML file listing every page you want search engines to index. Google can find pages by following links, but a sitemap makes sure nothing gets missed and tells Google when pages change.

Write the XML

The format is simple. One <url> block per page:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://yourdomain.com/</loc>
    <lastmod>2026-09-11</lastmod>
  </url>
  <url>
    <loc>https://yourdomain.com/about</loc>
    <lastmod>2026-08-02</lastmod>
  </url>
</urlset>

<loc> is required and must be the full absolute URL. <lastmod> is optional but worth including; Google uses it to decide what to recrawl. Skip <priority> and <changefreq>, which Google ignores.

Or let your framework generate it

Most frameworks and CMSs build the sitemap for you from your pages, so it never goes stale:

  • Next.js: add app/sitemap.ts that returns your URL list
  • WordPress: built in at /wp-sitemap.xml, or use the Yoast or Rank Math plugin
  • Astro, Hugo, Jekyll: an official sitemap plugin or setting

Prefer this over a hand-written file for anything with more than a handful of pages.

Put it at the site root

Save it as sitemap.xml at the root of your domain:

https://yourdomain.com/sitemap.xml

Open that URL in a browser. You should see the XML, not a 404.

Reference it in robots.txt

Add one line to your robots.txt:

Sitemap: https://yourdomain.com/sitemap.xml

Crawlers read robots.txt first, so this is how they discover the sitemap without being told.

Submit it to Google Search Console

In Search Console, open Sitemaps in the left menu, enter sitemap.xml, and click Submit. Within a day or two the status shows Success and how many URLs were found.

Limits. One sitemap can hold 50,000 URLs or 50 MB uncompressed. Larger sites split into several files and list them in a sitemap index, which uses the same format with <sitemap> blocks instead of <url>.

More Websites how-tos