Skip to content

What Is a Sitemap XML and How Do You Set It Up for Your Domain?

A sitemap XML lists the pages you want search engines to find. See how to build one, tie it to the right domain and submit it correctly.

10 min readUpdated Nov 28, 2026By XPASS Editorial Team

What Is a Sitemap XML and How Do You Set It Up for Your Domain?

When you publish a new page, a search engine does not know about it automatically. It has to discover the address, usually by following a link from a page it already knows. For a small, well-linked company site that works most of the time. For a growing site, a recent redesign or a set of pages buried several clicks deep, discovery becomes slower and less predictable. A sitemap XML file is the simplest way to hand search engines a tidy list of the pages you care about.

This article explains what a sitemap is, how it relates to your domain name and HTTPS setup, how to produce one, how to submit it and what to watch for. It sits alongside our guide on getting a company website found on Google, which covers the wider picture of search visibility. Here we stay on the sitemap itself and the domain-level details that decide whether it works.

What a sitemap XML actually is

A sitemap is a text file written in a simple XML format defined by the public sitemaps protocol. Each page you list is wrapped in a small record. The record always contains the full address of the page, called the loc value, and may include an optional lastmod value that holds the date the page last changed. The whole list sits inside a single wrapper element called urlset.

Two other optional values exist in the protocol, a change-frequency hint and a priority number. Google has said publicly that it ignores both, so you can leave them out. The two values that matter in practice are the address and, when you can keep it accurate, the last-modified date.

A sitemap does three useful things:

  • It lists your preferred addresses. If a page can be reached in several ways, the sitemap shows which version you consider the real one.
  • It speeds up discovery. New or rarely linked pages appear on the list even before other pages link to them.
  • It gives you a monitoring tool. Search Console reports how many of the submitted addresses were read and which ones had problems.

A sitemap does not force indexing, does not improve rankings by itself and does not replace good internal links. Think of it as a map you hand to a visitor who is already willing to look, not as a push.

Sitemap, robots.txt and the domain: who does what

Beginners often mix up three files and settings that sit near each other.

Item Where it lives Purpose
sitemap.xml Root of your site or a chosen path Lists pages you want found
robots.txt Root of your site Tells crawlers which paths they may or may not fetch
DNS records Your domain's DNS zone Point the domain name to the server that hosts the site

The robots.txt file follows the Robots Exclusion Protocol, published as RFC 9309. It is a polite request that well-behaved crawlers read before fetching anything else. A sitemap and a robots.txt file work together: one says what exists, the other says what is off limits. They should not contradict each other. If you list an address in the sitemap and block the same path in robots.txt, the crawler receives mixed instructions and the page usually stays out of the index.

DNS sits underneath both. If the domain name does not resolve to your server, neither file can be fetched. If you are still pointing your domain at a host, see the domain page for registration and DNS management, and keep the zone clean before you publish a sitemap that depends on it.

Why your domain setup decides whether the sitemap works

A sitemap is tied to a specific host. A crawler treats the main domain, the www version, a subdomain and the http and https versions as separate places. A few rules follow from that.

  1. Use one canonical host. Decide whether your site lives on the bare domain or on the www name, and use that same form in every address inside the sitemap.
  2. Use https everywhere. If your site has a valid certificate, list only https addresses. Mixing http and https entries sends a confusing signal. An SSL certificate is what makes the https version available in the first place, so confirm it is installed and not about to expire before you generate the file.
  3. Place the file on the same host it describes. A sitemap at the root of the main domain should list addresses on that same host. A sitemap cannot generally vouch for pages on a different host unless that host is verified separately.
  4. Redirect the alternatives. The other forms (http, the non-preferred www or non-www form) should send visitors and crawlers to the canonical form with a permanent redirect. Our guide to 301 redirects when changing a domain explains how to do this properly, and it matters again if you ever move to a new domain, because the sitemap must then be rebuilt with the new addresses.

If you manage several subdomains, such as a blog on one name and a shop on another, give each its own sitemap on its own host, or use a sitemap index that points to them where the rules allow it.

How to create a sitemap

There are three common routes. Pick the one that matches how your site is built.

Let your platform generate it

Most content management systems and website builders can produce a sitemap automatically. Some include it by default, others offer a setting or an add-on. The benefit is that the file updates itself when you publish or remove a page. Open the settings, find the sitemap option and note the address it publishes, which is often a path such as /sitemap.xml or /sitemap_index.xml.

Use a framework or build tool

If your site is built with a framework, there is usually a plugin or a small piece of code that writes the file during the build. Make sure it uses the production domain and the https scheme, not a local or staging address. A frequent error is a sitemap full of addresses pointing at a test environment because the base URL setting was never changed.

Write it by hand for a small site

For a handful of pages, a manual file is perfectly valid. Create a text file named sitemap.xml, add the XML declaration, open the urlset wrapper with the namespace defined by the protocol, add one record per page with its full address and optionally a date written as year, month and day, then close the wrapper. Save it in UTF-8, upload it to the root of the site and open it in a browser to confirm it loads. Any special characters inside an address, such as an ampersand, must be escaped as the protocol requires.

A plain example

Imagine a small consultancy with the domain example.co.th. The site has a home page, an about page, a services page, three service detail pages and a contact page. There is also a thank-you page shown after a form is submitted, and a staging copy that is protected by a password.

The owner decides on the bare domain with https as the canonical form, and takes these steps:

  1. Configures the platform so that the http and www versions redirect to the canonical https address.
  2. Generates a sitemap that lists the home page, about page, services page, three detail pages and contact page, eight addresses in total.
  3. Leaves the thank-you page out, because it has no value in search results, and leaves the staging site out entirely.
  4. Adds a line to robots.txt that gives the full address of the sitemap file.
  5. Submits the same address in Search Console and checks that all eight addresses are read.

Nothing here is complicated, but each step removes a possible source of confusion. The result is a clean list, a single canonical host and no contradictions between files.

Submitting your sitemap

You have two standard ways to announce the file, and they work well together.

Reference it in robots.txt. Add a line that starts with the word Sitemap, followed by a colon and the full address of the file, including https and the host. Because robots.txt is read early by most crawlers, this makes the sitemap discoverable by search engines other than Google as well.

Submit it in Search Console. In Google Search Console, open the property for your site, go to the Sitemaps report, enter the path of the file and submit. The report shows the status, the date it was last read and how many addresses were found. To use Search Console at all you must first prove that you control the domain, which is usually done with a DNS record; that process is covered in the separate guide on adding a domain to Search Console. A domain you manage yourself makes this step simple, so keep access to your DNS settings.

After submitting, give the system some time. A first read can take from hours to days, and a status of "success" only means the file could be parsed, not that every page is indexed.

Keeping the sitemap accurate

A sitemap that goes stale is worse than none, because it advertises addresses that return errors. Build a small routine.

  • Include only pages that return a normal, successful response. Leave out addresses that redirect, show errors, or are blocked from crawling.
  • Include only canonical pages. If two addresses show the same content, list the one you prefer.
  • Leave out thin or utility pages. Login screens, shopping carts, search result pages and thank-you pages seldom belong in search results.
  • Update the date only when the content really changes. If every page claims to have changed today, search engines learn to ignore the date.
  • Regenerate after structural changes. Redesigns, URL changes and domain moves all call for a fresh file.

When you restructure content so that it is easier for machines and people to read, the same clean list helps. The article on preparing a website for AI search looks at how clear structure and crawlable pages support newer kinds of search as well.

Limits and what to watch for

The protocol sets simple limits, and several common mistakes are worth knowing about.

Topic What to know
Size per file A single sitemap may hold up to 50,000 addresses and should not exceed 50 MB uncompressed
Many pages Split the list into several files and reference them from a sitemap index file
Encoding Use UTF-8 and escape special characters in addresses
Host match Addresses should belong to the host that serves the file
Scheme match Use https consistently if the site has a certificate
Indexing Submission is a hint; it never forces a page into the index

Common mistakes to avoid:

  • Listing redirected addresses. Put the final destination in the file, not the old address.
  • Listing addresses that return errors. Remove deleted pages promptly.
  • Blocking listed pages in robots.txt. The two files should agree.
  • Forgetting a certificate renewal. If the https version breaks, the sitemap fetch can fail and warnings appear in Search Console.
  • Leaving a staging address in a production file. Check the host in the first few entries every time you regenerate.
  • Expecting instant results. Indexing depends on many factors beyond the sitemap, including content quality and site reliability.

Also remember that a sitemap is public. Anyone can open it. Never include private or unlisted pages in it, because it would reveal their addresses to everyone.

A short checklist before you submit

  1. The domain resolves and the site loads over https with a valid certificate.
  2. One canonical host is chosen, and the alternatives redirect to it.
  3. The sitemap lists only canonical, successful, public pages.
  4. Every address uses the production host and the https scheme.
  5. The file is saved in UTF-8 and opens in a browser at the root of the host.
  6. robots.txt includes a Sitemap line and does not block the listed pages.
  7. The file is submitted in Search Console and re-checked after a few days.
  8. Your routine for regenerating the file after changes is written down.

Summary

A sitemap XML is a simple list that helps search engines discover the pages you consider important. It works best when the domain underneath is set up cleanly: one canonical host, https with a valid certificate, redirects from the alternatives and a robots.txt file that agrees with the list. Build the file with your platform or a plugin where possible, keep it accurate, announce it in robots.txt and Search Console, and treat it as a hint rather than a command. Re-check it whenever the structure of the site or the domain changes.

If you are still choosing or configuring a domain for your site, the domains page is a sensible place to start.

Frequently asked questions

What is a sitemap XML?

It is a plain file, usually placed at the root of your site, that lists the addresses of the pages you want search engines to know about. It can also carry the date each page last changed.

Do I need a sitemap if my site is small?

A small site with good internal links is usually discovered without one, but a sitemap is light to maintain and gives search engines a clean list of your preferred addresses. It helps most when pages are new, deep in the site or poorly linked.

Where should the sitemap file live?

Normally at the root of the exact host you want indexed, for example the main domain with a path such as /sitemap.xml. The addresses inside it should use the same host and the same https scheme.

Does a sitemap guarantee that Google will index every page?

No. A sitemap is a hint about what exists. Search engines still decide what to crawl and index based on quality, duplication, access rules and other signals.

How do I tell Google where my sitemap is?

Add a Sitemap line to your robots.txt file and submit the sitemap address in Google Search Console. Doing both is common and harmless.

About the author

Bob Kanokphon Thongdee, founder of XPASS VPN

Bob Kanokphon Thongdee

  • Founder of XPASS VPN
  • Co-founder of eSIMonline.asia
  • More than 7 years in online marketing
  • Founder of Cojourney Visa and Cojourney Travel

Start your website the right way

Register a domain, add SSL and set up business email from one place.

.com registration from $18.81 for the first year

Start with a domain

Keep reading

Website Guides

How to Get a Company Website Found on Google: Where to Start

A step-by-step starting point for making a company website easy for Google to find: domain, HTTPS, indexing, sitemap, content and measurement.

10 min read

Website Guides

What Is a 301 Redirect and How to Use It When Changing Domain

A 301 redirect is a permanent forwarding rule. This guide shows how to use it when you change domain: map old URLs, set rules, test them and avoid common mistakes.

9 min read

Website Guides

How to Prepare Your Website Content for AI Search

AI search tools summarise web pages into answers. Learn how to keep your site crawlable, clearly written and trustworthy, and what no one can promise.

10 min read