Skip to content
SEO

How to Create an XML Sitemap and Submit It to Google

By Published: 8 min read

XML sitemap file on laptop

An XML sitemap is a file that lists the pages on your site you want search engines to find. You can create XML sitemap files in three ways: with a built-in CMS feature or plugin, with a sitemap generator, or by writing the file by hand. After that, you submit the file's address in Google Search Console so Google knows where to find it. Submitting a sitemap helps search engines discover pages, especially new pages, deep pages, and pages with few internal links.

What an XML Sitemap Contains

An XML sitemap is a plain text file written in XML. Each page is wrapped in a url block. The loc tag holds the full address of the page, and the optional lastmod tag holds the date the page last changed in a meaningful way.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://www.example.com/</loc>
    <lastmod>2026-11-15</lastmod>
  </url>
  <url>
    <loc>https://www.example.com/blog/create-xml-sitemap/</loc>
    <lastmod>2026-11-20</lastmod>
  </url>
</urlset>

Every loc value must be a complete address that starts with the protocol, such as https://. All URLs in one sitemap should belong to the same host. If your site works on both www and non-www addresses, pick one and use it everywhere in the file.

Which URLs to Include

Include only the pages you want to appear in search results. These are usually indexable pages that load normally and return a success response. Leave out:

  • login pages
  • cart and checkout steps
  • internal search results
  • filter pages that only repeat content found elsewhere

Redirected URLs and duplicate versions of a page usually do not belong in the file. List the final address you want shown. A sitemap is only a weak signal about which version Google should treat as the main one. Canonical tags and redirects are the signals to rely on for that, so keep them correct as well.

Pages that carry a noindex directive should also be left out, because they are asking not to be indexed. A noindex line in robots.txt is not a reliable way to keep a page out of search results. Use a meta robots tag or an equivalent HTTP header on the page itself.

Create XML Sitemap Files: Three Options

The right method depends on how your site is built and how often its pages change. The table below compares the three common approaches. Whichever you pick, the file it produces has the same tag structure, shown in the image below.

Method Best for Trade-off
CMS feature or plugin Blogs and stores built on a content management system You must check the settings and exclusions
Sitemap generator Sites without a built-in option, or a one-time audit The output must be cleaned before use
Hand-written file Very small sites with a few stable pages You must update it manually, and errors are easy to miss

XML sitemap tag structure

Use a CMS Feature or Plugin

Many content management systems create a sitemap automatically, either as a built-in feature or through a plugin. After you enable it, open the sitemap address, usually /sitemap.xml, and confirm that it lists the pages you expect. Remove the page types you decided to leave out in the previous section. Automatic files usually update as you publish, so this method needs the least work over time.

Use a Sitemap Generator

A sitemap generator crawls your site from a starting address and writes a sitemap from the pages it can reach. This suits sites without a built-in option. Generators can be desktop software or online services.

Before you use the output, remove URLs that should not be indexed. A crawler finds everything it can reach, including test pages, staging copies, and parameter variations, so review the list line by line.

Write the File by Hand

For a small site with a few pages, a text editor is enough. Start from the example above, add one url block per page, and save the file as sitemap.xml in the root folder of your site.

In XML, an ampersand must be written as &amp;. A URL with query parameters, such as ?category=shoes&color=red, must have each & escaped in the file.

Check the File Before You Submit

Open the sitemap address in a browser while logged out. It should load and show the XML, not an error page or a login screen. Then check the structure:

  • The file is saved as UTF-8.
  • Each loc value is a full address on one host.
  • Special characters such as &, <, and > are escaped.
  • Every listed URL opens and returns a normal page.
  • The tags are closed and nested correctly.

An XML validator or the XML linting feature in your editor can catch missing closing tags and bad characters. Check the file again after every change, because a single broken tag can stop the whole file from being read.

Splitting Large Sites Into Several Files

A single sitemap file has a limit on the number of URLs and on its uncompressed size. When a site grows past those limits, split the URLs across several sitemap files and list them in one sitemap index file. The index file points to the sitemap files, not to individual pages.

Compressing a sitemap with gzip is optional. It reduces the bandwidth needed to download the file, but it does not change how you should count the URLs. Check the current limits in the official documentation before you build large files, because they can change.

Place the File and Reference It in robots.txt

Put the file at the root of your domain, for example at https://www.example.com/sitemap.xml. If you place it in a subfolder, it can describe only the URLs under that folder unless you submit it through Search Console for the whole property. You can also add a Sitemap line to your robots.txt file so crawlers can find the file without a separate submission:

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

The address in that line must be complete, with the protocol and host. Make sure robots.txt does not block the sitemap file or the pages it lists.

Submit the Sitemap in Google Search Console

Submitting a sitemap requires that you own the site property. Verify ownership first, then follow this general process:

  1. Open the property that matches your site, such as the one for https://www.example.com/.
  2. Go to the section where you submit sitemaps.
  3. Enter the path to your file, such as sitemap.xml.
  4. Submit it, then check the status report.

The report shows whether Google could read the file and any processing errors. Processing can take time, so check the status again later rather than right away. If the status shows an error, read the section below before you change anything else.

Common Errors and Fixes

Most problems with a sitemap fall into a few groups. The table below matches the symptom to its usual cause and fix.

Symptom Likely cause Fix
The file cannot be read or fetched The address is wrong, the file returns a 404 error, or access is blocked Open the address while logged out, correct the path, and check robots.txt and server permissions
The file cannot be parsed A broken tag, an unescaped character, or a wrong encoding Validate the XML and fix the encoding or escaping (see the checks above)
URLs are listed but not recognized The protocol or host does not match the site Use the same https:// and host as the live site in every loc
Many listed URLs are not indexed See the indexing section below Check the pages, their canonical tags, and internal links
Dates in the report look old lastmod is not updated when content changes Set lastmod to the real change date

Indexing Is Not Guaranteed

A sitemap helps search engines discover URLs, but discovery is not the same as indexing. A sitemap does not guarantee that every listed page will be crawled or indexed, and it does not raise rankings on its own. A page can be crawled after you submit the file and still stay out of search results. Thin content, duplicate content, a noindex directive, or weak internal links often keep pages out of the index, and a sitemap cannot fix those problems.

If a listed page is missing, start with the page itself. Open it, confirm that it returns real content, check for a noindex directive, and check its canonical tag. Then use the URL inspection tool in Search Console to see what Google last recorded for that address.

An indexed page is not guaranteed to rank, or to appear for any particular query. Indexing only means the page is eligible to be shown.

Priority and Changefreq Values

Some older sitemap examples include priority and changefreq tags. Google ignores these two values, so you do not need them. The sitemap protocol describes changefreq only as general information that may not match how often crawlers actually visit a page.

Keep the Sitemap Current

Update the file when you publish, move, or remove pages. Remove deleted URLs so the file does not send crawlers to dead ends. This matters most for hand-written files, which do not update themselves.

Use lastmod to record the date a page last changed in a meaningful way, such as new content, a revised price, or a corrected section. If every generated file uses today's date for every page, the value tells search engines nothing useful. Generators that set one date for all pages should be configured to read the real modification date instead.

Frequently asked questions

Do small sites need an XML sitemap?

Not always. A small site whose pages link to each other clearly may be discovered without one. A sitemap still helps list every page you want found, and if you include the optional `lastmod` tag, it records when each page last changed.

Can I submit an HTML sitemap page instead?

Not in place of an XML file. An HTML page that links to your important pages helps visitors and can help crawlers follow links, but Search Console expects an XML sitemap file for submission.

Related posts

SEO

Can You Decrypt an MD5 Hash? How MD5 Really Works

Decrypting MD5 is not possible because MD5 is a one-way hash, not encryption. Weak passwords can still be matched by testing candidates, and salt prevents generic precomputed tables.

· 7 min read