SEO & SERP•
12 min read

How to Create a Sitemap for Google: Step-by-Step Guide

You publish a new page and then wait. Learn how to create an XML sitemap for Google, submit it in Search Console, and fix common indexing errors fast.

Faiz Naseem
Faiz Naseem
Founder & Lead Technical Architect
Published on
How to Create a Sitemap for Google: Step-by-Step Guide

Key Takeaways

  • An XML sitemap lists your canonical, indexable URLs (status 200) so Google discovers new and updated pages faster.
  • Submitting a sitemap is a hint, not a command—keep it clean by excluding redirects, 404s, and noindex pages.
  • Let your CMS or build pipeline generate it automatically, or use a sitemap generator or script for custom sites.
  • Submit your sitemap.xml or sitemap_index.xml in Google Search Console and reference its full URL inside robots.txt.
Interactive Web Utility

Try Our Free XML Sitemap Generator

Build a clean, valid XML sitemap for Google with properly formatted <urlset>, <loc>, and <lastmod> tags in seconds. Fast, instant execution directly in your web browser with no software download required.

Generate XML Sitemap

You publish a new page and then wait. Days go by and Google still has not found it. A sitemap is one of the simplest ways to fix that. It is a file that lists the pages you want search engines to know about and it takes very little effort to set up.

This guide shows you how to create a sitemap for Google from start to finish. You will learn the formats Google accepts and the easiest ways to build one. You will also see how to submit it and how to fix the errors that tend to appear afterward. Each step works for a small blog and a large online store. You can also generate a clean file immediately with our XML Sitemap Generator or inspect an existing site with our XML Sitemap Finder.

What Is a Sitemap?

A sitemap is a file that lists the important URLs on your website. Search engines read it to learn what pages exist and when they last changed. Most sitemaps are XML files following the sitemaps.org XML protocol, and the usual name is sitemap.xml.

Think of it as a table of contents for your site. Google can still find pages by following links. The sitemap gives it a direct list so nothing gets missed.

How Google Uses Your Sitemap 1. sitemap.xml Lists canonical URLs + lastmod dates 2. Faster Discovery Googlebot finds new & updated pages 3. Quality Evaluation Hint only — quality & crawlability decide index A sitemap speeds up URL discovery, but it does not force Google to index low-value pages
Figure 1: A sitemap helps Google discover pages but does not guarantee indexing.

One point matters a lot. Submitting a sitemap is a hint and not a command. Google may not download it right away and it may not crawl every URL inside it. A sitemap speeds up discovery. It does not force indexing.

Do You Really Need a Sitemap?

Not every site does. Google Search Central notes that a small and well-linked site may not need one. A sitemap helps most in these cases:

  • Large sites. Thousands of pages are easy to miss without a list.
  • New sites. Few other sites link to you yet so Google has fewer paths to find your pages.
  • Sites with weak internal linking. Some pages may sit several clicks deep or have no links at all.
  • Sites with rich media. Image sitemaps and video sitemaps give Google extra detail.
  • Sites that change often. News sites and shops add and remove pages all the time.

Even if you do not strictly need one the cost is close to zero. Most platforms create it for you. A sitemap also gives you reports in Search Console that show how Google handles your URLs.

Sitemap Formats Google Supports

Google accepts a few formats. XML is the most common and the most flexible.

Format Best For Notes
XML sitemap Almost every site Supports extra data like images and videos
RSS or Atom feed Blogs with a feed Only lists recent URLs
Text file Very simple sites One URL per line and nothing else

Whichever format you pick there are a few rules to follow:

  • The file must be encoded in UTF-8.
  • A single sitemap can hold up to 50,000 URLs or 50 MB uncompressed. Larger sites need several sitemaps.
  • Use full absolute URLs. Include the protocol and the host.
  • List only canonical URLs (check yours with our Canonical URL Checker). These are the versions you want shown in search results.

Before You Start: Decide Which URLs to Include

A sitemap works best when it is clean. It should list pages that you want in search and nothing else. A messy sitemap sends mixed signals and makes errors harder to spot.

Which URLs Belong in Your Sitemap? ✓ Include These URLs • Canonical, indexable pages (HTTP 200) • Core service, product, and tool pages • Blog posts and evergreen guides • Important category landing pages ✗ Leave Out These URLs • Pages with a noindex meta tag • 301/302 redirects and 404/410 pages • Duplicate parameter or filter URLs • Login, cart, checkout, and admin URLs
Figure 2: Include indexable canonical pages and leave out everything else.

Before you generate the file ask a quick question about each URL. Is it a real page that returns status 200 and can be indexed? If yes then include it. If it redirects or errors or carries a noindex tag then leave it out.

Three Ways to Create a Sitemap

Pick the method that fits your site. Most people should start with the first one.

Three Ways to Create a Sitemap Recommended 1. Built-in CMS WordPress, Shopify, Wix Auto-updates on publish Static & Custom 2. Generator / Build Crawlers, Next.js, Astro Export & upload to root Small Sites (< 50 URLs) 3. Manual XML / Script Write sitemap.xml directly Full control over tags
Figure 3: Three ways to create a sitemap.

Method 1: Let Your CMS Create It

This is the easiest route and Google recommends it. Many platforms generate and update a sitemap on their own. You usually just need to know where to find it.

Platform Typical Sitemap Address
WordPress core /wp-sitemap.xml
WordPress with Yoast SEO or Rank Math /sitemap_index.xml
Shopify /sitemap.xml
Wix and Squarespace /sitemap.xml

Open the address in your browser to confirm it works. If you use an SEO plugin on WordPress check its settings. You can usually choose which post types and taxonomies appear and which are left out. Also turn off any second sitemap. Running the built-in WordPress one next to a plugin sitemap can create duplicates.

A CMS sitemap has one big advantage. It updates itself every time you publish or delete a page. You never have to remember to regenerate it.

Method 2: Use a Sitemap Generator

If your site is built by hand or with a static site tool you can use a generator. These tools crawl your site or format your URL list into an XML file.

  • Desktop crawlers. Screaming Frog can crawl a site and export an XML sitemap. It lets you filter out redirects and noindex pages before you export.
  • Online generators. Free web tools like our XML Sitemap Generator let you build a clean, spec-compliant XML file to download in seconds.
  • Static site plugins. Frameworks like Next.js, Astro, and Hugo have built-in support or plugins that build a sitemap during the site build.

After you generate the file upload it to your site root. Then check it for URLs that should not be there. Crawl-based tools often pick up parameter URLs and old redirects that you will want to delete.

Method 3: Create a Sitemap Manually

For a site with only a few dozen pages you can write the file yourself. Open a plain text editor and save a file called sitemap.xml. Here is a simple example:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://www.yoursite.com/</loc>
    <lastmod>2026-11-20</lastmod>
  </url>
  <url>
    <loc>https://www.yoursite.com/about/</loc>
    <lastmod>2026-10-05</lastmod>
  </url>
  <url>
    <loc>https://www.yoursite.com/blog/how-to-create-a-sitemap/</loc>
    <lastmod>2026-12-01</lastmod>
  </url>
</urlset>
Anatomy of an XML Sitemap <urlset xmlns=".../sitemap/0.9"> <url> <loc>https://example.com/</loc> <lastmod>2026-12-01</lastmod> </url> Root wrapper + XML namespace Container for each single URL Full canonical page URL (required) Last meaningful update date
Figure 4: The main parts of an XML sitemap.

Each tag has a clear job:

Tag Required? What It Does
<urlset> Yes Wraps the whole file and declares the sitemap protocol
<url> Yes Holds the details for one page
<loc> Yes The full canonical URL of the page
<lastmod> Optional The date of the last significant update
<priority> Optional Ignored by Google
<changefreq> Optional Ignored by Google

Google ignores the <priority> and <changefreq> values so you can skip them. The <lastmod> tag is useful only when it is honest. Google uses it when it is consistently accurate. Do not set every page to today’s date. Update it only when the content changes in a meaningful way.

Special characters in a URL must be escaped. For example an ampersand becomes &amp;. This is a common source of parsing errors.

Method 4: Generate It with a Script

If you run a custom site you may prefer to build the file from your own data. The script below creates a valid sitemap from a list of pages. It is short on purpose so you can adapt it to your database or content files.

from xml.sax.saxutils import escape

pages = [
    ("https://www.yoursite.com/", "2026-11-20"),
    ("https://www.yoursite.com/blog/", "2026-12-01"),
    ("https://www.yoursite.com/contact/", "2026-09-14"),
]

lines = [
    '<?xml version="1.0" encoding="UTF-8"?>',
    '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
]
for url, modified in pages:
    lines.append("  <url>")
    lines.append(f"    <loc>{escape(url)}</loc>")
    lines.append(f"    <lastmod>{modified}</lastmod>")
    lines.append("  </url>")
lines.append("</urlset>")

with open("sitemap.xml", "w", encoding="utf-8") as f:
    f.write("\n".join(lines))

Run it as part of your build or deploy so the file stays current. The escape function handles special characters for you.

Large Sites: Use a Sitemap Index

Once you pass 50,000 URLs or 50 MB you need more than one file. You can also split a sitemap by content type to keep things tidy. A sitemap index file lists your individual sitemaps. You then submit only the index.

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://www.yoursite.com/sitemap-pages.xml</loc>
    <lastmod>2026-12-01</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://www.yoursite.com/sitemap-posts.xml</loc>
    <lastmod>2026-12-01</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://www.yoursite.com/sitemap-products.xml</loc>
    <lastmod>2026-11-28</lastmod>
  </sitemap>
</sitemapindex>

Splitting by type has a bonus. Search Console reports on each sitemap separately. You can see right away if your product pages have errors while your blog is fine.

Special Sitemaps for Images, Video and News

If media or news content matters to your business you can add dedicated sitemaps:

  • Image sitemaps help Google find images that load through scripts.
  • Video sitemaps give details like title and duration and thumbnail.
  • News sitemaps are for publishers that appear in Google News.

Most small sites do not need these. Add them only when the content type is a real part of your strategy.

Where to Put Your Sitemap

Place the file at the root of your site. A common address is https://www.yoursite.com/sitemap.xml. You can host it elsewhere on your site but a sitemap only covers URLs in its own folder and below unless you submit it in Search Console. Root placement avoids that limit.

Make sure the file is public. Pages behind a login or blocked by robots.txt cannot be read by Google.

How to Submit Your Sitemap to Google

Creating the file is half the job. Now tell Google where it is. There are three ways and you can use more than one.

Submit Your Sitemap in Google Search Console 1. Sign In Choose your property 2. Open Sitemaps From the left sidebar 3. Enter Path e.g. sitemap.xml 4. Click Submit Monitor status & URLs
Figure 5: Four quick steps to submit a sitemap in Search Console.

Option 1: Search Console

This is the best option because it also gives you reports (official Google sitemap documentation):

  1. Sign in to Google Search Console and choose your property.
  2. Open Sitemaps in the left menu.
  3. Under Add a new sitemap type the path to your file such as sitemap.xml.
  4. Click Submit.

Submit only the sitemap or the sitemap index. You do not need to submit every child file when you use an index.

Option 2: Add it to robots.txt

Add this line anywhere in your robots.txt file (or generate one with our Robots.txt Generator):

Sitemap: https://www.yoursite.com/sitemap.xml

Google finds it the next time it crawls your robots.txt file. Other search engines read the same line too. It works well next to a Search Console submission. If you need help with that file read our guide on how to check robots.txt.

Option 3: The Search Console API

Developers can submit sitemaps with the Search Console Sitemaps API. This is useful for agencies that manage many properties.

Google used to offer a ping address for sitemaps. That feature has been retired so do not rely on it.

How to Check Your Sitemap Status

Return to the Sitemaps report a day or so after you submit. You will see a status for each file.

Status What It Means What to Do
Success Google fetched and processed the file Nothing. Keep an eye on the discovered URL count
Has errors The file loaded but some entries failed Open the report and fix each listed issue
Couldn’t fetch Google could not read the file Check the URL and server response and robots.txt

Also look at the Page indexing report. You can filter it by your sitemap to see which submitted pages are indexed and which are not. This is the most useful view for finding problems.

Common Sitemap Errors and How to Fix Them

Problem Likely Cause Fix
Couldn’t fetch Wrong URL or server error or a block Open the URL in a browser and check for status 200
Invalid XML or parsing error Unescaped characters or a missing tag Validate the file and escape special characters
URLs not allowed A URL sits outside the sitemap’s folder or uses another host Move the file to the root or submit through Search Console
Submitted URL blocked by robots.txt A Disallow rule matches the URL Remove the block or remove the URL from the sitemap
Submitted URL has a noindex tag A page you listed asks not to be indexed Remove the tag or take the URL out
Submitted URL not found (404) The page was deleted Remove it from the sitemap
Redirect in sitemap The listed URL points somewhere else List the final destination URL instead

Sitemap Mistakes to Avoid

  • Listing every URL. Filters and parameters and thin pages dilute the file. Keep it focused.
  • Setting fake dates. If every lastmod says today Google learns to ignore it.
  • Including noindex or redirected pages. This creates conflicting signals.
  • Leaving an old sitemap online. Stale files full of dead URLs cause errors for months.
  • Forgetting HTTPS and www consistency. Use the exact version of the site that you want indexed.
  • Treating it as a ranking tool. A sitemap helps discovery. It does not improve rankings.

Sitemap Best Practices Checklist

Step Check
1 Only canonical and indexable URLs are listed
2 Every URL returns status 200
3 The file is UTF-8 and under 50,000 URLs or 50 MB
4 URLs use the correct protocol and host
5 The lastmod values are accurate
6 The sitemap is linked in robots.txt
7 It is submitted in Search Console
8 The Sitemaps report shows Success
9 The file updates automatically when content changes

How Often Should You Update Your Sitemap?

A sitemap should always match your live site. If it comes from a CMS or a build script it updates itself. If you maintain it by hand update it whenever you add or remove a page. Review the Sitemaps report once a month and after every migration or big release. You do not need to resubmit the file each time. Google rechecks it on its own, and you can verify your setup anytime with our Deep Website SEO Audit Tool or on-page SEO audit guide.

Conclusion

Creating a sitemap for Google is simple. Let your CMS or a sitemap generator build the file and keep it clean. Then submit it in Search Console and add it to robots.txt. Check the report after a day or two and fix any errors that show up.

Start today by opening /sitemap.xml on your own site. If it loads and lists only the pages you care about you are most of the way there. If it does not then use the steps above to build one in under an hour.

Topics:#sitemap#XML sitemap#how to create a sitemap#Google Search Console#technical SEO
Got Questions?

Frequently Asked Questions

No. Google can find pages through links. A sitemap makes discovery faster and more complete and it is especially useful for new and large sites.

Faiz Naseem
Written ByVerified Expert

Faiz Naseem

Founder & Lead Technical Architect

Faiz Naseem is the founder and lead technical architect of Daily Digital Tools. He specializes in high-performance web engineering, client-side media pipelines, privacy-first tooling, and data-driven technical SEO architectures.

Full-Stack Web Architect • W3C Standards & Technical SEO Specialist
Recommended Reading

You Might Also Like

Browse all guides