How to Create and Submit a sitemap.xml
Yuuuk94·Published
Summary
sitemap.xml is an XML file that tells search engines "these are the URLs on my site". Google can find pages by following links without one, but new sites with few external links and large sites get discovered more slowly.
What matters more than having the file is what goes in it. List only the canonical URLs you want in search results; leave out noindex pages, redirecting URLs and duplicates.
01Basic format
Sitemaps follow the protocol defined at sitemaps.org. The simplest form is a <url> with a single <loc>. <lastmod> (last modified date) is optional but helps when it is accurate.
<?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-11-01</lastmod>
</url>
<url>
<loc>https://yourdomain.com/blog/first-post</loc>
<lastmod>2026-11-10</lastmod>
</url>
</urlset>| Tag | Required | Does Google use it? |
|---|---|---|
| loc | Yes | Yes. Must be a full URL starting with https:// |
| lastmod | No | Yes, if it is consistently accurate |
| changefreq | No | Ignored |
| priority | No | Ignored |
Many generators add changefreq and priority by default, but Google says it ignores them. They don't hurt, but don't spend time on them. On the other hand, stamping every page's lastmod with the build time destroys trust in it; use the date the content actually changed.
02What to include and what to leave out
A sitemap is a list that says "please index these URLs". Mixing in URLs you don't want indexed sends conflicting signals, which is why Search Console shows warnings like "Submitted URL marked 'noindex'".
| Include | Leave out |
|---|---|
| Home, key feature pages, blog posts | Pages with noindex |
| Canonical URLs that point to themselves | URLs that redirect elsewhere |
| Each language's canonical URL on multilingual sites | Search, filter and sort parameter URLs |
| Pages viewable without logging in | Login, account and checkout pages |
03Size limits and sitemap index files
A single sitemap can hold up to 50,000 URLs and 50 MB uncompressed. Beyond that, split it into several files and create a sitemap index that lists them; then submit just the index URL.
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://yourdomain.com/sitemap-pages.xml</loc>
</sitemap>
<sitemap>
<loc>https://yourdomain.com/sitemap-blog.xml</loc>
</sitemap>
</sitemapindex>Even on smaller sites, splitting by type lets you see per-group status in Search Console, for example how many blog posts are indexed.
04Generating it in common frameworks
Maintaining a sitemap by hand means forgetting to add new pages. Most frameworks can generate it at build or request time.
| Setup | How |
|---|---|
| Next.js (App Router) | Return an array of URLs from app/sitemap.ts and it is served at /sitemap.xml. You can read your posts to set lastModified. |
| WordPress | Core provides /wp-sitemap.xml since 5.5; SEO plugins replace it with their own. |
| Static site generators | Gatsby, Astro, Hugo and others have official plugins or built-in support. |
| Custom server | Add one route that reads public pages from your database and returns XML. |
05How to submit it
- Reference it in robots.txt: add
Sitemap: https://yourdomain.com/sitemap.xmlat the bottom. Google and Bing both read it. - Google Search Console: enter the sitemap URL under Indexing > Sitemaps. Processing status and discovered URL counts appear there.
- Bing Webmaster Tools: submit it there too, or import your Search Console property. Bing's index also feeds some AI search products.
Google used to accept sitemap pings at google.com/ping?sitemap=..., but it retired that endpoint in 2023. Today the supported routes are robots.txt, Search Console submission and an accurate lastmod.
06What to check after submitting
- The status in Search Console's Sitemaps screen is "Success". "Couldn't fetch" usually means a 404 or a robots.txt block.
- The discovered page count is close to the number of URLs you listed.
- In Indexing > Pages, filtered by sitemap, why unindexed URLs aren't indexed.
- No URLs in the sitemap use http, another domain, or a development address.
Submitting a sitemap doesn't mean every URL gets indexed. It helps discovery; indexing depends on quality and duplication. For a step-by-step diagnosis see site not showing up on Google.
FAQ
- Q. Does a small 10-page site need a sitemap?
- Not strictly. Google finds a small, well-linked site on its own. But a sitemap costs almost nothing and makes indexing status easier to follow in Search Console, so it is worth having.
- Q. Do I need to resubmit after updating the sitemap?
- Not if the URL is the same; Google rereads submitted sitemaps periodically. If it is urgent, submit the same URL again in Search Console.
- Q. Can I include images and videos?
- Yes, there are image, video and news extensions. For a typical service site, accurate page URLs are enough.
Related reading
References
How does your site do?
Enter one URL to run the free SEO/AEO/GEO checklist, including everything covered in this post.
Check for free