SEO & Marketing

What is an XML sitemap?

XML sitemap

A sitemap is a file where you provide information about the pages, videos, and other files on your site, and the relationships between them. Search engines like Google read this file to more intelligently crawl your site.

The sitemap tells Google which pages and files you think are essential to your site, and also provides valuable information about these files: for example, pages, when the page was last updated, how often the page is changed, and any alternate language versions of a page.

If your site’s pages are properly linked, Google can usually discover most of your site. Even so, a sitemap can improve the crawling of larger or more complex sites or more specialised files.

How to create a sitemap

When creating a sitemap, you’re telling search engines about which URLs you prefer to show in search results. These are the canonical URLs. If you have the same content accessible under different URLs, choose the URL you prefer and include that in the sitemap instead of all URLs that lead to the same content.

Once you’ve decided which URLs to include in the sitemap, pick one of the following ways to create a sitemap, depending on your site architecture and size:

  • Let your CMS generate a sitemap for you.
  • For sitemaps with less than a few dozen URLs, you can manually create a sitemap.
  • For sitemaps with more than a few dozen URLs, automatically generate a sitemap.

Let your CMS generate a sitemap for you

If you’re using a CMS such as WordPress, Wix, or Blogger, it’s likely that your CMS has already made a sitemap available to search engines. Try searching for information about how your CMS generates sitemaps, or how to create a sitemap if your CMS doesn’t generate a sitemap automatically. For example, in case of Wix, search for “wix sitemap”.

For all other site setups, you will need to generate the sitemap yourself.

Manually create a sitemap

For sitemaps with less than a few dozen URLs, you may be able to manually create a sitemap. For this, open a text editor such as Windows Notepad or Nano (Linux, MacOS), and follow a syntax described in the Sitemap Formats section.

You can manually create larger sitemaps, but it’s a tedious process.

Automatically generate a sitemap

For sitemaps with more than a few dozen URLs, you will need to generate the sitemap. There are various tools that can generate a sitemap. However, the best way is to have your website software generate it for you. For example, you can extract your site’s URLs from your website’s database and then export the URLs to either the screen or actual file on your web server. Talk to your developers or server manager about this solution. If you need inspiration for the code, check out our old collection of third-party sitemap generators.

Keep in mind that sitemaps can’t be larger than 50 MB. Learn more about managing large sitemaps.

Submit your sitemap to Google

Google doesn’t check a sitemap every time a site is crawled; a sitemap is checked only the first time that we notice it, and thereafter only when you ping us to let us know that it’s changed. Alert Google about a sitemap only when it’s new or updated; don’t submit or ping unchanged sitemaps multiple times.

If you have updated pages in the sitemap, mark them with the <lastmod> field. Other XML files have a similar field, such as <updated> for Atom XML. You can also learn how to compute this date.

There are a few different ways to make your sitemap available to Google:

Submit a sitemap in Search Console using the Sitemaps report.
Use the ping tool. Send a GET request in your browser or the command line to this address, specifying the full URL of the sitemap. Be sure that the sitemap file is accessible:

https://www.google.com/ping?sitemap=FULL_URL_OF_SITEMAP

Example:

https://www.google.com/ping?sitemap=https://example.com/sitemap.xml

Insert the following line anywhere in your robots.txt file, specifying the path to your sitemap. We will find it the next time we crawl your robots.txt file:

Sitemap: https://example.com/my_sitemap.xml

Use WebSub if you use Atom/RSS for your sitemap and want to broadcast your changes to other search engines in addition to Google.
Submitting a sitemap is merely a hint: it doesn’t guarantee that Google will download the sitemap or use the sitemap for crawling URLs on the site.

Leave a Reply

Your email address will not be published. Required fields are marked *