XML sitemap: what it is and how to set it up in Drupal

Digital graphic illustrating global data surveillance and analysis, with a magnifying glass on a world map connected to icons representing code processing, servers, and documents.

When working on your website's SEO, one of the most important (and often overlooked) elements is the sitemap. This file serves as a map for search engines, helping them discover and index all relevant pages on your site.

Although ideally Google should be able to crawl all pages through internal links, in practice, many are left out of that crawl: new pages, sections with few links, or content hosted deep within the site. That's where the sitemap comes in.

A sitemap allows search engines to find every important page on your website faster, even those that don't have direct internal links. In other words, it speeds up the content discovery process and improves indexing coverage.

What is a sitemap and why is it important?

A sitemap is a file that contains a structured list of a website's pages. Its main purpose is to facilitate the work of web crawlers, allowing them to identify what content exists, when it was last updated, and how relevant it is within the site.

Additionally, it helps search engines index your website more efficiently, increasing the likelihood that your pages will appear in results when people search for terms related to your content or services.

Although Google does not consider sitemaps a mandatory requirement, it does recommend them as a best practice, especially for large sites with many internal pages or few links. In general, having a sitemap makes the work of search engines easier and helps your content be discovered and indexed faster.

Types of sitemaps and their differences

There are different types of sitemaps, each with a specific purpose:

  • Visual sitemap: mainly used during the web design process to plan the site structure, but has no direct impact on SEO.
  • HTML sitemap: designed for site visitors. It functions as an index that brings together the main links on a single page, facilitating navigation, and is usually located in the menu or footer.
  • XML sitemap: this is the format preferred by search engines because it brings together all the important URLs on the site along with useful metadata, such as the date of the last update, the frequency of changes, or the priority of each page.

Although the three types serve different purposes, XML has the greatest impact on SEO, as it directly communicates to Google how your site is structured. It also allows extensions to include additional metadata (for example, information about images, videos, news content, or localized versions of pages), making it the best option when you need to communicate extra details to search engines.

How to create an effective XML sitemap

Before generating your sitemap, it's a good idea to define which pages to include. Not all URLs should appear in it. The rule is simple: if you don't want a page to appear in search results, don't include it in the sitemap.

For example, avoid including test pages, duplicate content, thank you pages, or internal search results. Instead, prioritize sections that are relevant to your users: product pages, services, blog articles, or categories.

A basic XML sitemap looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://www.example.com/services/</loc>
    <lastmod>2024-01-01</lastmod>
  </url>
</urlset>

In this fragment:

  • <?xml version="1.0" encoding="UTF-8"?> indicates the file type..
  • <urlset> defines the set of URLs.
  • <loc> shows the exact page address.
  • <lastmod> indicates the date of the last modification.

Una vez creado, puedes comprobarlo escribiendo en tu navegador: https://yoursite.com/sitemap.xml

And, to facilitate indexing, it is recommended that you send it directly to Google Search Console.

How to do it in Drupal step by step

If your site is developed in Drupal, creating an XML sitemap is easier than it seems, thanks to the Simple XML Sitemap module. Here are the steps to configure it:

Step 1: Log in to Drupal.

Step 2: Install the Simple XML Sitemap module from the official website.

Step 3: Activate the necessary submodules

  • Simple XML Sitemap
  • Simple XML Sitemap (Search engines)
  • (Optional) Simple XML Sitemap (Views) if you use the Views module.

Step 4: Go to Configuration → Search and metadata → Simple XML Sitemap.

Step 5: Select Rebuild queue & generate to create your first sitemap.

In the Settings tab, you can adjust how often the file is regenerated and define whether the sitemap will be displayed with an XSL stylesheet to make it more readable.

From the Inclusion tab, you can also add custom links, comments, images, or other elements that add value depending on your content type.

At Seed EM, we often use this module as part of the basic SEO configurations for Drupal projects, as it allows us to generate accurate sitemaps and keep them updated automatically.

The impact of an XML sitemap

An XML sitemap not only organizes your site for search engines but also improves how Google understands the hierarchy and relevance of your content. Although indexing also depends on other factors (such as content quality and internal links), a good sitemap is a solid foundation for your website to be discovered faster and more accurately.

Drupal simplifies this process with tools such as Simple XML Sitemap, which automate the generation and updating of the file, ensuring that every new relevant page is visible to search engines.

Creating and maintaining an XML sitemap may seem like a technical detail, but it is actually a key part of any modern SEO strategy. And with flexible platforms such as Drupal, doing it well is within everyone's reach.