← Back to blog
How to Create an XML Sitemap and Submit It to Google

How to Create an XML Sitemap and Submit It to Google

By The RankLoco Team · August 18, 2026

To create an XML sitemap for Google, generate a file that lists every important URL on your site (most CMS platforms and plugins do this automatically), place it at yourdomain.com/sitemap.xml, then submit that URL in Google Search Console under the Sitemaps report. Google reads the file to discover and prioritize your pages for crawling. That is the whole job in three moves: generate, publish, submit.

Below is the full process, including how to build a sitemap by hand if you need to, what to include and exclude, how to submit it correctly, and how to read the errors Google throws back at you.

What an XML sitemap actually does (and what it does not)

An XML sitemap is a machine-readable list of the URLs you want search engines to know about. Each entry can carry metadata like the last modified date. Think of it as a table of contents you hand directly to Google so it does not have to rely only on following links to find your pages.

Here is what a sitemap does not do: it does not guarantee indexing, it does not boost rankings, and it does not fix thin or duplicate pages. Submitting a URL is a suggestion, not a command. Google still decides what to index based on quality and crawl priority. A sitemap simply removes the excuse that Google "never found" your page.

Sitemaps matter most for large sites, new sites with few backlinks, sites with poor internal linking, and sites with pages that are not well linked from the main navigation. If you run a five-page brochure site that is already fully linked, a sitemap is nice to have but not critical.

What to include in your XML sitemap

Only list URLs you actually want indexed. A messy sitemap full of junk trains Google to trust it less. Include:

  • Canonical URLs only (the version you want to rank, not duplicates or parameter variations)
  • Pages that return a 200 status code
  • Indexable pages (no noindex tag)
  • Live, published content: your key landing pages, blog posts, product and category pages

Leave these out:

  • Redirected URLs (301 or 302)
  • 404 or broken pages
  • Pages blocked by robots.txt or tagged noindex
  • Duplicate URLs, faceted navigation variants, and internal search results
  • Utility pages like thank-you pages, admin, cart, and login screens

If you run an ecommerce store, be especially careful with parameter and filter URLs. Those bloat your sitemap and create indexing confusion. Our guide on how to fix duplicate content issues on an ecommerce site covers exactly which variants to keep out.

How to create an XML sitemap: 4 methods

Method 1: Use your CMS or SEO plugin (easiest)

Most platforms generate and update a sitemap automatically. This is what 90% of sites should use because it stays current with zero maintenance.

  • WordPress: Yoast SEO, Rank Math, or All in One SEO all create a sitemap index. Yoast puts it at /sitemap_index.xml, Rank Math at /sitemap_index.xml as well. WordPress core also ships a basic sitemap at /wp-sitemap.xml.
  • Shopify: automatically generates /sitemap.xml. You cannot edit it directly, but it updates as you add products and pages.
  • Wix and Squarespace: both auto-generate a sitemap at /sitemap.xml.
  • Webflow: enable auto-sitemap in site settings, or upload a custom one.

Find your sitemap by typing common paths into your browser: /sitemap.xml, /sitemap_index.xml, or /wp-sitemap.xml. If one loads, you already have a sitemap.

Method 2: Use a sitemap generator tool

If your platform does not produce one, a crawler-based generator will build it for you. Point the tool at your homepage, let it crawl, and download the resulting XML file. This is a one-time snapshot, so you will need to regenerate it whenever you add pages. That manual upkeep is why plugins beat generators for most sites.

Method 3: Build it by hand (for small or custom sites)

For a handful of URLs on a custom-built site, you can write the file yourself. The format is simple:

  • Start with the XML declaration and the urlset opening tag with the sitemaps.org namespace.
  • Wrap each page in a url block containing a loc tag (the full URL) and optionally a lastmod tag (last modified date in YYYY-MM-DD format).
  • Close the urlset tag.

A single entry looks like this in plain terms: url, then loc with https://yourdomain.com/page, then lastmod with 2025-01-15, then close url. Repeat for each page. Save the file as sitemap.xml with UTF-8 encoding and upload it to your root directory. Keep the lastmod dates accurate; faking them wastes crawl budget when Google recrawls pages that have not changed.

Method 4: Use a sitemap index for large sites

A single sitemap file is capped at 50,000 URLs or 50MB uncompressed. If you exceed that, split URLs across multiple sitemaps and reference them all in a sitemap index file. Many sites also split by content type: one sitemap for posts, one for pages, one for products, one for images. This makes it far easier to diagnose which section has indexing problems in Search Console.

How to submit your sitemap to Google Search Console

Once the file is live, submit it so Google processes it faster. You need a verified Search Console property first. If you have not set that up, do it before anything else, because it is where you will monitor everything.

  1. Log in to Google Search Console and select your property.
  2. In the left menu, click Sitemaps under the Indexing section.
  3. In the "Add a new sitemap" field, enter the path after your domain, for example sitemap.xml or sitemap_index.xml. You do not type the full domain; Search Console already knows it.
  4. Click Submit.
  5. Wait. Status will show "Success" once Google fetches it. It can take minutes to a few days for Google to process the URLs.

You can submit multiple sitemaps to the same property. If you have a sitemap index, submitting just the index file is enough; Google reads the child sitemaps from it.

Add the sitemap to your robots.txt too

List your sitemap in robots.txt so other search engines (Bing, DuckDuckGo) find it without manual submission. Add a line: Sitemap: https://yourdomain.com/sitemap.xml at the bottom of the file. This is belt-and-suspenders and takes ten seconds.

Reading the Sitemaps report and fixing errors

After submission, the Sitemaps report shows the status and how many URLs were discovered. Click into your sitemap to see indexing details. Here are the issues you will actually run into:

Error or statusWhat it meansFix
Couldn't fetchGoogle could not access the fileCheck the URL loads in a browser and is not blocked by robots.txt
Has errorsInvalid XML or unreachable URLs insideValidate the file format and remove broken links
Discovered but not indexedGoogle found the URL but chose not to index yetImprove content quality, internal links, and crawl priority
Submitted URL not found (404)Sitemap lists dead pagesRemove 404s from the sitemap
Submitted URL has noindexConflicting signalsRemove either the noindex tag or the URL from the sitemap

The gap between "discovered" and "indexed" URLs is the number that tells the real story. If Google discovered 500 URLs but indexed 120, your sitemap is fine; your content or site architecture is the problem. Strengthen your internal linking strategy so important pages get more internal signals, and clean up the crawl issues flagged in the Google Search Console crawl errors report.

Sitemap best practices that keep it working

  • Keep it clean. Every URL should be canonical, indexable, and return a 200. Audit it quarterly.
  • Let it auto-update. A dynamic sitemap that reflects new content beats a static file you forget to regenerate.
  • Use accurate lastmod dates. Only update them when the page content genuinely changes.
  • Do not list every page. Prioritize pages that earn traffic and conversions. Skip thin utility pages.
  • Match your canonicals. The URL in the sitemap must be identical to the canonical tag on the page, including trailing slashes and protocol.
  • Create an image or video sitemap if media drives your traffic. This pairs well with optimizing images for SEO and faster page speed.

A sitemap is one piece of your technical foundation. Once it is submitted and clean, work through the rest of our technical SEO checklist to catch the fixes that actually move rankings. Then use a tool like RankLoco to run a site audit and track whether those newly indexed pages start climbing. For more step-by-step guides, browse the full RankLoco blog.

Frequently Asked Questions

How long does it take Google to process a submitted sitemap?

Google usually fetches the sitemap within minutes to a few days. The Sitemaps report will show "Success" once fetched. Actual indexing of the listed URLs takes longer, from days to weeks, depending on your site's crawl priority, authority, and content quality.

Do I need an XML sitemap if my site is small?

Not strictly. If your site has a handful of pages that are all linked from the navigation, Google will find them by crawling. But a sitemap costs nothing and removes any doubt, so it is still worth submitting even for small sites, especially brand-new ones with few backlinks.

Where should my sitemap be located?

Place it in your root directory so it is accessible at yourdomain.com/sitemap.xml. It can only include URLs from the domain and subdomain where it lives. A sitemap on your root cannot list URLs from a different subdomain unless you use cross-submission via Search Console.

What is the difference between an XML sitemap and an HTML sitemap?

An XML sitemap is for search engines and uses a structured format they parse to discover URLs. An HTML sitemap is a page for human visitors that links to your key pages. XML helps crawling and indexing; HTML helps user navigation and internal linking. Larger sites often use both.

Why does Google say my URL is discovered but not indexed?

Google found the URL through your sitemap but decided not to index it, usually because the content is thin, duplicative, or low priority. The fix is not resubmitting the sitemap. Improve the page's quality, add internal links pointing to it, and make sure it satisfies real search intent.

How often should I update my XML sitemap?

If you use a plugin or CMS that generates it dynamically, it updates automatically every time you publish. If you built it manually, regenerate and resubmit whenever you add, remove, or significantly change pages. You do not need to resubmit for minor edits.

Keep reading

How to Estimate Search Volume for Keywords Without a Paid Tool How to Estimate Search Volume for Keywords Without a Paid Tool How to Set Up Rank Tracking by Location and Device How to Set Up Rank Tracking by Location and Device How to Optimize Google Business Profile Posts for Local Search How to Optimize Google Business Profile Posts for Local Search