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.tsthat 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
- How to Add a Favicon to a Website
- How to Add a Website to Bing Webmaster Tools
- How to Add a Website to Google Search Console
- How to Add Alt Text to Images
- How to Add Google Analytics to a Website
- How to Add Open Graph Tags to a Website
- How to Add Structured Data to a Web Page
- How to Check DNS Propagation
- How to Check If a Website Is Indexed by Google
- How to Compress Images for a Website
- How to Connect a Domain to Vercel
- How to Make a Website Mobile-Friendly
- How to Move a Domain to Cloudflare DNS
- How to Redirect www to non-www
- How to Set a Canonical URL
- How to Set Up a 301 Redirect
- How to Set Up Email Forwarding for a Domain
- How to Write a Meta Description
- How to Write a robots.txt File