Jump to content
KUHM

Create a Google Sitemap and Submit It to Search Console

Posted on - Updated

Create a Google Sitemap and Submit It to Search Console

A sitemap is an XML file that lists a site's addresses (URLs) and the date they were last modified, to help Google discover pages it would struggle to find by following links. Creating one takes a few minutes; it is then submitted through Search Console or declared in the robots.txt file.

Google is not omniscient, even though it constantly evolves. It does not visit all your pages at once: it discovers the site, then crawls it and indexes it gradually. If your pages are linked to each other with real HTML links, this works, but it takes time.

A sitemap becomes valuable in several cases: links generated in JavaScript that the crawler follows poorly, pages with few or no links between them, a new site with no inbound links, or hundreds of pages published at once. Without a sitemap, some of these pages may stay invisible for a long time.

Keep one limit in mind: according to Google's documentation, submitting a sitemap is only a suggestion. It helps discovery, but it guarantees neither the indexing nor the ranking of a page.

What is an XML sitemap?

An XML sitemap is a simple text file, structured according to the sitemaps.org protocol, that gathers your pages (URLs) and, if you wish, their last modification date. Google accepts other formats (RSS, plain text file), but XML remains the most common and the most complete.

Create a Google sitemap in 3 steps

  1. Create your XML file (details below).
  2. Upload this file to the right location.
  3. Submit the sitemap to Google through Search Console, or declare it in the robots.txt.

Writing the sitemap.xml file

The sitemap is an XML file, preferably named sitemap.xml. Any text editor will do, even Notepad, as long as you save the file in UTF-8.

Two rules from Google's documentation prevent most read errors. Every address must be a fully qualified, absolute URL (https://www.exemple.com/page/, never just /page/). And, as in any XML file, every tag value must be entity escaped: an ampersand inside a URL is written &, an apostrophe ', a less-than sign <. A single unescaped character can make the whole file unreadable for the crawler.

It must start with:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

For each URL on your site, add a <url> block:

<url>                                  (required)
  <loc>https://www.exemple.com/</loc>    (required)
  <lastmod>2009-12-09</lastmod>        (optional)
  <changefreq>daily</changefreq>       (optional)
  <priority>0.8</priority>             (optional)
</url>

And it must end with:

</urlset>

The tags Google actually reads

loc
The full address of the page. It starts with the protocol (https:// on a secure site, http:// otherwise); the trailing slash is only required if your server demands it. It must be shorter than 2,048 characters.
lastmod
The date of the page's last significant modification, in YYYY-MM-DD format (the time can be added). Google uses it if it is consistent and verifiable: a date that changes every time the file is generated, without any real change to the content, ends up being ignored.

changefreq and priority: two tags Google ignores

The changefreq tag indicates the page's presumed update frequency (always, hourly, daily, weekly, monthly, yearly, never). The priority tag gives a relative priority between your URLs, from 0.0 to 1.0, with a default value of 0.5. The protocol still provides for them, but Google states in its documentation that it ignores the values of these two tags: there is no point spending time setting them for Google. Other engines may still read them, so they do no harm. The same goes for other legacy markup, such as the meta keywords tag and what Google, Bing and Yandex do with it.

Where to place your sitemap?

The sitemap can be located anywhere on the site, but unless it is submitted through Search Console, it only covers the addresses located in its folder and the folders below it. Google therefore recommends publishing it at the root of the site.

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

These will be taken into account:
https://www.exemple.com/monrep/index.html
https://www.exemple.com/index.html
https://www.exemple.com/rep1/rep2/index.html

These will be ignored:
https://exemple.com/morep/index.html
https://sousdomaine.exemple.com/

Sitemap example 2: https://www.exemple.com/monrep/sitemap.xml

These will be taken into account:
https://www.exemple.com/monrep/index.html
https://www.exemple.com/monrep/sousdos/index.html

These will be ignored:
https://www.exemple.com/index.html
https://www.exemple.com/rep1/rep2/index.html
https://sousdomaine.exemple.com/monrep/index.html

What is the maximum size of a sitemap?

A sitemap must not exceed 50 MB uncompressed, nor contain more than 50,000 URLs. Beyond that, you need to split it into several files and group them in a sitemap index file, which you submit to Google instead of the separate files. The size limit is measured on the uncompressed file, so a compressed copy that looks small can still be too large.

Also remember to include only the pages you want to see in Google: redirected, erroring or blocked addresses muddy the signal and end up flagged as anomalies in the report.

Submitting your sitemap to Google

The old Webmaster Tools are now called Search Console. Submission is done in the "Sitemaps" report: you paste the file's address there, then Google displays its status (read, any errors, number of pages discovered). Setting up Search Console on your site is therefore the prerequisite.

Another, complementary option: declare the sitemap in the robots.txt file by adding, anywhere in it, a line like this:

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

Every engine that reads robots.txt will then find the sitemap, with no action required from you for each one.

One old shortcut no longer works: the Google ping address that some scripts and plugins called after every update. On June 26, 2023, Google announced it was deprecating its support for sitemaps ping, with the endpoint to stop functioning within 6 months; requests sent to it now return a 404 error. Search Console and the robots.txt line remain the ways to point Google to the file. An accurate lastmod does the rest: Google explained in the same announcement that it uses this date as a signal for scheduling crawls of URLs it has already discovered, which is why the date should only change when the page really changes.

Generate your sitemap automatically

Writing the file by hand only makes sense for a very small site. Beyond that, an automatically generated sitemap is better, as it tracks page additions and removals without intervention:

  • on WordPress, recent versions produce a native sitemap (wp-sitemap.xml), and SEO plugins such as Google XML Sitemaps offer their own, with more settings;
  • most CMSs and online store solutions also generate their own;
  • for a static site, a site crawling tool can produce the file, to be regenerated with each update.

The sitemap is not everything: pages that are well linked together, with image alt attributes filled in, are still better understood by Google, and a well-targeted topic is prepared beforehand by looking for new keywords with Google Suggest.

Google adjusts these rules from time to time, as it did with the ping endpoint; the main announcements are followed in the search engine news on Google, Bing and Yahoo.

About the author

Cyril KUHM

Cyril KUHM

Head of MKH, a web agency near Strasbourg, and SEO consultant since 2007. On this blog I share free, hands-on advice to help your site rank better on Google.

Get in touch

Related posts

↑