Crawling

Sitemaps

Everything you need to know about how to create and interpret a sitemap

Sitemaps
Author
Carlos Sánchez
Topics
Crawling International LinkBuilding
Published
Reviewed

An SEO Sitemap will be a web file containing a list of URLs where it indicates to search engines which URLs are relevant.

Depending on the type of Sitemap, additional factors can be specified, such as the last update, whether that URL contains relevant images or videos, or even whether it has an alternative language or “regional” version.

Sitemaps are especially recommended for large websites, with a large amount of multimedia files or with poor linking. Ideally, these Sitemaps should be automated, as it is difficult to keep the Sitemap of any minimally large website up to date.

Since there are options as simple as adding a Sitemaps with the main URLs in a txt file, or a basic XML implementation, and it does not harm rankings or performance, I personally recommend always doing it (clearly in a lower order of priority, below more necessary tasks), as it is quite common for a website’s external/internal linking and architecture not to stand out for being exemplary.

General characteristics of any Sitemap

It is useful to know that you do not need to put all URLs in the same Sitemap nor do you necessarily have to do it only for robots. It is great if you can segment it into blocks to detect errors and make it useful and understandable for humans. Here is an example of what mine would look like (to see the code you can right-click and choose “view page source”, or if you are on mobile add “view-source:” before the URL).

Sitemap XML

An XML Sitemap is the most complete type of Sitemap, as it allows us to offer Google a lot of information about the characteristics of the URLs that we want to indicate to the search engine as indexable.

Basic Sitemap

In a basic XML Sitemap, we simply need to focus on placing the URLs according to the semantics of Sitemaps designed for SEO.

On a website with a standard alphabet, we must always start with this code in the .xml file to indicate the type of encoding:

<?xml version="1.0" encoding="UTF-8"?>

Having explained this, I show an example of a basic and standard sitemap. I will include only one URL so that the characteristics can be clearly seen and appreciated:

<?xml version="1.0" encoding="UTF-8"?>
<!-- If you want to add a nice style, you can use mine -->
<?xml-stylesheet href="https://sanchezdonate.net/wp-content/themes/sanchezdonate/core/css/stylesheet.xsl
" type="text/xsl"?>

<!-- you need to set the correct attribute in urlset, with the proper xmlns; for a simple sitemap this is enough: -->
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
>
<url>
<loc>https://sanchezdonate.net/</loc>
<lastmod>2023-05-24</lastmod>
</url>
</urlset>

Attributes

The lastmod attribute must be used with care, since from June 2023 they emphasize using lastmod only when there are significant changes on the page.

Update 30/10/2026: What Google's documentation says today: use lastmod only if it is consistently and verifiably accurate (for example, compared with the actual last modification of the page), and it should reflect the last significant change, such as one to the main content, the structured data or the links; updating the copyright year does not count. The format is W3C Datetime, so the date alone (YYYY-MM-DD) or the date with time and time zone are both valid. And according to the protocol, the date is that of the last modification of the page, not the date the sitemap was generated.

The rest of the attributes, such as changefreq or priority, are irrelevant, as Google does not read them and they can make the page heavier.

Image Sitemap

The rest of the specific sitemaps are actually like an extension of a basic Sitemap, but with the "image library" added, with the attribute and URL exactly as in the example, and with the corresponding tags inside <url>.

What is done by adding images to a sitemap is to indicate the important images present on a URL.

<?xml version="1.0" encoding="UTF-8"?>
<!-- If you want to add a nice style, you can use mine -->
<?xml-stylesheet href="https://sanchezdonate.net/wp-content/themes/sanchezdonate/core/css/stylesheet.xsl" type="text/xsl"?>
<!-- you need to set the correct attribute in urlset, with the proper xmlns; for a simple sitemap this is enough: -->
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
>
<url>
<loc>https://master-testing.com/&lt;/loc></span>
<lastmod>2023-05-24</lastmod>
<image:image>
<image:loc>https://sanchezdonate.net/wp-content/themes/sanchezdonate/images/sanchez-white-seo.svg&lt;/image:loc>
</image:image>
</url>
</urlset>

Attached is an example of an image Sitemap that you can view by right-clicking and selecting "view page source".

Attributes

The rest of the existing attributes for an image-specific sitemap have been obsolete since May 6, 2022.

Update 30/10/2026: To be precise, on May 6, 2022 Google announced that it was deprecating image:caption, image:geo_location, image:title and image:license, and since August 6, 2022 they no longer affect indexing (if they are still in your sitemap, they don't break it). Two details from the current documentation: each <url> can contain up to 1,000 image:image tags, and the image can be on another domain (for example, on a CDN) as long as you have verified both domains in Search Console.

Not understanding this?
If you need help with the more technical aspects, book a consultancy session with me: Get real SEO help!

Video Sitemap

It is not necessary to include the image sitemap to include the video sitemap. One extension does not depend on another.

This type of Sitemap makes sense on websites that use a lot of videos, such as TV channel sites. It is especially recommended to indicate the URLs where the main feature is the video and to combine it with structured data for video.

Recommendations for a video sitemap:

<?xml version="1.0" encoding="UTF-8"?>
<!-- If you want to add a nice style, you can use mine -->
<?xml-stylesheet href="https://sanchezdonate.net/wp-content/themes/sanchezdonate/core/css/stylesheet.xsl" type="text/xsl"?>
<!-- You need to add the correct attribute in urlset, with the correct xmlns. For a simple sitemap, this is enough:-->
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
>
<url>
<loc>https://master-testing.com/</loc>
<lastmod>2023-05-24</lastmod>
<image:image>
<image:loc>https://sanchezdonate.net/wp-content/themes/sanchezdonate/images/sanchez-white-seo.svg</image:loc>
</image:image>
<video:video>
<video:thumbnail_loc>https://i.ytimg.com/vi_webp/f5-07hStg4A/maxresdefault.webp</video:thumbnail_loc>
<video:title>Cookies and Cache in SEO</video:title>
<video:description>Discover what cookies and cache are, how they affect a website, and how to use them to your advantage in SEO</video:description>
<video:player_loc>https://www.youtube.com/embed/f5-07hStg4A</video:player_loc>
<!-- Optional video tags -->
<video:duration>5198</video:duration>
<video:publication_date>2023-05-24</video:publication_date>
<video:family_friendly>yes</video:family_friendly>
<video:rating>5.0</video:rating>
<video:view_count>3000</video:view_count>
<video:restriction relationship="allow">ES MX US</video:restriction>
<video:platform relationship="allow">mobile</video:platform>
<video:requires_subscription>yes</video:requires_subscription>
<video:uploader>Carlos Sánchez</video:uploader>
<video:live>no</video:live>
<video:tag>cookies</video:tag>
<video:tag>cache</video:tag>
<video:tag>servers</video:tag>
<video:tag>wpo</video:tag>
<video:tag>seo</video:tag>
<video:tag>technical seo</video:tag>
</video:video>
</url>
</urlset>

Mandatory Attributes

In the official documentation, there is a detail of each and every one of these attributes.

As can be seen, there are many attributes that are required for the video sitemap to work.

Update 30/10/2026: I am correcting the list: it used to show content_loc and player_loc as if both were required, which is why my example, which only has player_loc, looked incomplete. According to the video sitemap reference, you need at least one of them. Google recommends content_loc (the URL of the video file) whenever possible, because it is the most effective way for it to fetch the video, and player_loc (the URL of the player) as the alternative; with YouTube, Vimeo and other platforms embedded with an iframe, you use player_loc, as in the example. Neither of them can be the same URL as the page's <loc>.

Optional Attributes

Update 30/10/2026: Each video:tag holds a single tag and is repeated for each one, up to 32 per video; in the examples I had them all together separated by commas, and I have now split them. video:duration is in seconds, from 1 to 28,800 (8 hours). And in the same 2022 clean-up Google removed video:category, video:gallery_loc, video:price, video:tvshow and the autoplay and allow_embed attributes of video:player_loc, so don't add them.

News Sitemap

News Sitemaps are more complicated to implement correctly, which is why I recommend reading the instructions carefully. However, this type of Sitemap is highly crawlable by Google, as it is one of the fastest ways to get indexed.

The fastest way to index would be through the Indexing API, but it is recommended only for streaming videos and job postings, i.e., for “ephemeral indexing,” so using the Indexing API implementation could be considered Black-hat since it requires having the appropriate structured data.

Update 30/10/2026: The Indexing API documentation is still clear about it: it can only be used for pages with JobPosting or BroadcastEvent embedded in a VideoObject. In addition, all submissions go through spam detection, and if it is abused (for example, with several accounts to get around the quotas) Google may revoke your access.

In conclusion, the fastest/most efficient way to index a news article or post, besides using the Search Console URL Inspection tool, is through a News Sitemap.

<?xml version="1.0" encoding="UTF-8"?>
<!-- If you want to add a nice style, you can use mine -->

<?xml-stylesheet href="https://sanchezdonate.net/wp-content/themes/sanchezdonate/core/css/stylesheet.xsl" type="text/xsl"?>

<!-- you need to add the correct attribute in urlset, with the correct xmlns, for a simple sitemap this is enough: -->


<urlset

xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"

xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"

xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"

xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
>

<url>


<loc>https://master-testing.com/</loc>

<lastmod>2023-05-24</lastmod>


<image:image>

<image:loc>https://sanchezdonate.net/wp-content/themes/sanchezdonate/images/sanchez-white-seo.svg</image:loc>

</image:image>


<video:video>


<video:thumbnail_loc>https://i.ytimg.com/vi_webp/f5-07hStg4A/maxresdefault.webp</video:thumbnail_loc>

<video:title>Cookies and Cache in SEO</video:title>

<video:description>Discover what cookies and cache are, how they affect a website, and how to use them to your advantage in SEO</video:description>

<video:player_loc>https://www.youtube.com/embed/f5-07hStg4A</video:player_loc>


<!-- Optional video tags -->


<video:duration>5198</video:duration>

<video:publication_date>2023-05-24</video:publication_date>

<video:family_friendly>yes</video:family_friendly>

<video:rating>5.0</video:rating>

<video:view_count>3000</video:view_count>

<video:restriction relationship="allow">ES MX US</video:restriction>

<video:platform relationship="allow">mobile</video:platform>

<video:requires_subscription>yes</video:requires_subscription>

<video:uploader>Carlos Sánchez</video:uploader>

<video:live>no</video:live>

<video:tag>cookies</video:tag>
<video:tag>cache</video:tag>
<video:tag>servers</video:tag>
<video:tag>wpo</video:tag>
<video:tag>seo</video:tag>
<video:tag>technical seo</video:tag>

</video:video>

<news:news>

<news:publication>

<news:name>The equivalent of the h1</news:name>

<news:language>es</news:language>

</news:publication>

<news:publication_date>2023-05-24</news:publication_date>

<news:title>Make up another title or copy the existing one</news:title>


</news:news>

</url>

</urlset>

Mandatory Attributes:

For a news sitemap to be effective, it must include these tags as required.

A news sitemap must be updated with new articles as they are published. In this specific sitemap, it makes more sense than in any other that the URL is not static.

Articles must be no older than 2 days, and after this period, the URLs must be removed from the sitemap or the tags and subtags belonging to <news:news> must be deleted

Update 30/10/2026: According to Google's documentation, a news sitemap can contain up to 1,000 news:news tags; if you have more, you have to split it into several. What you update is the same sitemap, you don't create a new one for each news article. And if you don't publish anything for two days and it ends up empty, that's fine.

Sitemap Index

A sitemap index is a sitemap of sitemaps. Since there is a restriction on size and number of links, it is ideal for long websites. I also like it to divide the site on different sections and, when automated, to keep the sitemaps organized. Additionally, it makes error detection much easier.

This is how a Sitemap Index would look:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="wp-content/themes/sanchezdonate/core/css/stylesheet.xsl" type="text/xsl"?>
<sitemapindex
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://sanchezdonate.net/sitemap.xml</loc>
</sitemap>
<sitemap>
<loc>https://sanchezdonate.net/sitemap-posts.xml</loc>
</sitemap>
</sitemapindex>

Update 30/10/2026: The limits of the index, according to Google's documentation and the protocol: up to 50,000 sitemaps per index and 50MB uncompressed. The sitemaps it lists have to be on the same site as the index and in the same directory or below it (except with multi-site submission), and in Search Console you can submit up to 500 index files per site. Each <sitemap> can also have an optional <lastmod> with the modification date of that sitemap.

Language Sitemap

If you want to implement a language sitemap, you must understand how hreflang work. n addition to pointing to the different language versions, it is important that they are referenced as self-referencing and that the concepts are clear, such as what x-default consists of.

Remember the guidelines common to all implementation methods. This is the most practical solution for a system of pages in different languages with different domains or even servers, as maintenance and implementation are much simpler than doing it via meta tags or servers.

This is because you only need to replace the XML files and ensure that each URL matches its alternate versions across domains.

Not all URLs need an alternate version, but for safety, Google will only consider an hreflang when it is indicated from the different versions.


This is how hreflangs work

When hosted on the same domain

<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>http://hreflang.test/</loc>
<xhtml:link
rel="alternate"
hreflang="es"
href="http://hreflang.test/es"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="http://hreflang.test/"/>
</url>
<url>
<loc>http://hreflang.test/es</loc>
<xhtml:link
rel="alternate"
hreflang="en"
href="http://hreflang.test/"/>
<xhtml:link
rel="alternate"
hreflang="es"
href="http://hreflang.test/es"/>
</url>
</urlset>

When using different domains

As mentioned, this is the most practical case, so each XML file must be in its language version. Here is a basic example:

Spanish format
<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>http://hreflangtest.es</loc>
<xhtml:link
rel="alternate"
hreflang="en"
href="http://hreflangtest.uk/"/>
<xhtml:link
rel="alternate"
hreflang="es"
href="http://hreflangtest.es"/>
</url>
</urlset>
Format on the English domain
<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>http://hreflangtest.uk/</loc>
<xhtml:link
rel="alternate"
hreflang="en"
href="http://hreflangtest.uk/"/>
<xhtml:link
rel="alternate"
hreflang="es"
href="http://hreflangtest.es"/>
</url>
</urlset>

TXT Sitemap

If you don’t want to complicate things, you can always create a .txt file (please don’t call it robots) and place it in the root folder.

This Sitemap offers very little customization, but it allows a simple list of URLs with the most important pages of the website.

This is quite useful as a temporary patch while the proper Sitemap is being programmed, thanks to its easy handling. But it is not scalable or efficient for large projects.

Feed Sitemap

If you have a blog with RSS, MRSS, or Atom 1.0, your feed can serve as a Sitemap. The advantage of Google accepting this format is that most CMSs generate it automatically and fairly well. Moreover, most articles on a website are indexable. Therefore, for a simple site, it is a great option to have a fully automated Sitemap naturally without the need for plugins (a post sitemap).

Update 30/10/2026: Google accepts RSS 2.0 and Atom 1.0 feeds, and mRSS to give it information about videos, but it warns that a feed only gives it information about recent URLs. So if you want the feed to cover more posts, raise the number of items it shows (in WordPress, Settings > Reading > "Syndication feeds show the most recent").

Remember not to be a genius and block the /feed/ via robots.txt as most negligent misinformers recommend if you intend to use this system.

Automating Sitemaps

As you can see, they may seem complex to update and manage efficiently, especially the news sitemap.

But no matter how complex they appear manually, if programmed and automated, it becomes a fairly simple, personalized, and scalable process.

That is, the ideal approach is to create the template and automate it, so your site processes it every time an update is received.

To do this or learn how to improve it aesthetically, I cannot explain it in a single post. But it is covered in the SEO Master's program. So if you want to become a sitemap expert, don’t hesitate.

Bibliography

If you like this article, you would help me a lot by sharing my content:
Training
Interested in Advanced SEO Training?

I currently offer advanced SEO training in Spanish. Would you like me to create an English version? Let me know!

Tell me you're interested
You might be interested in other articles:
SEO Articles