Dev.to WebDev 🛠 Dev 👁 2 📖 12 min read

XML Sitemap Explained: How to Create, Validate and Submit an XML Sitemap to Search Engines

XML Sitemap Explained: How to Create, Validate and Submit an XML Sitemap to Search Engines Introduction An XML sitemap is an important technical SEO resource that helps search engines discover URLs on a webs

XML Sitemap Explained: How to Create, Validate and Submit an XML Sitemap to Search Engines

Introduction

An XML sitemap is an important technical SEO resource that helps search engines discover URLs on a website. It provides information about the pages that website owners want search engines to know about and can make URL discovery more efficient.

Whether you manage a personal blog, business website, eCommerce store, news website, or large web application, maintaining a properly structured XML sitemap is an important part of website management.

However, creating a sitemap is only one part of the process. Developers also need to understand XML formatting, URL requirements, sitemap limitations, validation, and submission through search engine tools.

Incorrect sitemap entries, outdated URLs, broken XML structures, and unnecessary URLs can make sitemap maintenance more difficult.

This is where technical SEO knowledge and appropriate online utilities become useful.

Tools.QBMFX.com is a browser-based platform for exploring online tools and developer utilities that support everyday website management and technical workflows.

In this guide, we will explain what an XML sitemap is, why websites need one, how to create a sitemap, how to validate its structure, and how to submit it to Google Search Console.

1. What Is an XML Sitemap?

An XML sitemap is a structured file that lists URLs associated with a website.

It helps search engines discover pages that website owners consider important.

An XML sitemap generally follows the Sitemap Protocol and uses XML elements to describe individual URLs.

A basic sitemap looks like this:

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

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

  <url>
    <loc>https://example.com/</loc>
  </url>

  <url>
    <loc>https://example.com/about/</loc>
  </url>

  <url>
    <loc>https://example.com/contact/</loc>
  </url>

</urlset>

In this example:

  • urlset is the root element.
  • url represents an individual URL entry.
  • loc contains the absolute URL of the page.

The XML sitemap should follow the supported protocol and contain properly formatted URLs.

A typical sitemap is available at:

https://example.com/sitemap.xml

However, website owners can use other sitemap locations as long as the location is properly communicated to search engines.

2. Why Is an XML Sitemap Important for SEO?

Search engines discover webpages through links, sitemaps, and other discovery mechanisms.

An XML sitemap provides an additional way to communicate which URLs are available on a website.

A. Helping Search Engines Discover URLs

Some websites have complex navigation structures or large numbers of pages.

An XML sitemap can help search engines discover URLs that may be difficult to find through internal links alone.

This is particularly useful for:

  • Large websites
  • News websites
  • eCommerce websites
  • Websites with frequently updated content
  • Websites with newly published pages

B. Supporting Website Changes

When new pages are published, website owners can update their XML sitemaps to include the new URLs.

This helps communicate changes to search engines.

However, submitting a sitemap does not guarantee that every URL will be crawled or indexed.

C. Communicating Important URL Information

Sitemaps can include additional information such as the last modification date.

For example:

<url>
  <loc>https://example.com/seo-guide/</loc>
  <lastmod>2026-11-25</lastmod>
</url>

The lastmod element can communicate when a page was last significantly modified.

It should represent a genuine modification date rather than being changed automatically without a meaningful content update.

D. Supporting Large Websites

Websites with many URLs may need multiple sitemap files.

The Sitemap Protocol supports up to 50,000 URLs or 50 MB uncompressed per sitemap file.

For larger websites, sitemap indexes can be used to reference multiple sitemap files.

3. Understanding Important XML Sitemap Elements

Before creating a sitemap, developers should understand its main XML elements.

A. XML Declaration

The XML declaration identifies the XML version and character encoding.

Example:

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

This is commonly included at the beginning of an XML sitemap.

B. URL Set

The urlset element acts as the root container for URL entries.

Example:

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

The namespace identifies the Sitemap Protocol vocabulary.

C. Location (loc)

The loc element contains the absolute URL of a webpage.

Example:

<url>
  <loc>https://example.com/services/</loc>
</url>

Each URL should use the correct preferred version of the page.

D. Last Modified (lastmod)

The lastmod element communicates the last significant modification date of a page.

Example:

<url>
  <loc>https://example.com/blog/seo-guide/</loc>
  <lastmod>2026-11-25</lastmod>
</url>

Google may use this information when it is consistently accurate and verifiable.

E. Change Frequency and Priority

Older sitemap examples often contain:

<changefreq>weekly</changefreq>
<priority>0.8</priority>

These elements are part of the Sitemap Protocol, but Google ignores both changefreq and priority.

Therefore, developers targeting Google Search do not need to rely on these elements to influence crawling.

4. How to Create an XML Sitemap Manually

Creating a basic XML sitemap does not require complicated software.

Developers can create one using a text editor.

Step 1: Collect Important Website URLs

Prepare a list of URLs that you want to include.

For example:

https://example.com/
https://example.com/about/
https://example.com/services/
https://example.com/contact/

Include URLs that are important and intended to be available for search engines.

Step 2: Create an XML File

Open a plain-text editor such as Notepad or Visual Studio Code.

Create a new file and add the following structure:

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

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

  <url>
    <loc>https://example.com/</loc>
  </url>

  <url>
    <loc>https://example.com/about/</loc>
  </url>

  <url>
    <loc>https://example.com/services/</loc>
  </url>

  <url>
    <loc>https://example.com/contact/</loc>
  </url>

</urlset>

Replace the example URLs with your actual website URLs.

Step 3: Save the File

Save the document with this filename:

sitemap.xml

Make sure the editor saves it as an XML file rather than a text file with an additional .txt extension.

Step 4: Upload the Sitemap

Place the file in the appropriate public directory of your website.

For a conventional hosting environment, the structure may look like this:

public_html/
    index.html
    robots.txt
    sitemap.xml

For static websites, the sitemap can be generated during the build process and deployed to the website's public root.

Step 5: Verify Its Accessibility

Open the sitemap URL:

https://example.com/sitemap.xml

Confirm that the file loads and displays valid XML.

5. How to Generate an XML Sitemap Automatically

Manually maintaining a sitemap can become difficult when a website contains hundreds or thousands of URLs.

Automated sitemap generation can make maintenance easier.

A. Static Website Generators

Modern static website frameworks can generate sitemap files during the build process.

For example, Astro projects can use the official sitemap integration.

Documentation:

https://docs.astro.build/en/guides/integrations-guide/sitemap/

A simplified Astro configuration may look like this:

import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';

export default defineConfig({
  site: 'https://example.com',
  integrations: [
    sitemap()
  ]
});

The integration can generate sitemap files as part of the build process.

B. Content Management Systems

Many content management systems provide sitemap generation through built-in functionality or extensions.

For example, WordPress websites can generate XML sitemaps automatically.

Developers should check the sitemap output after installation or configuration changes.

C. Custom Sitemap Generation

Web applications with dynamic content may generate sitemap files programmatically.

A custom sitemap generator can retrieve URLs from a database, content management system, or application data source.

The generated XML should always be checked for valid structure and correct URLs.

6. How to Validate an XML Sitemap

Creating an XML sitemap does not guarantee that it is correctly structured.

Validation helps identify errors before submitting the file to search engines.

A. Check XML Syntax

A valid XML document must follow proper syntax rules.

For example, the following XML contains a missing closing tag:

<urlset>
  <url>
    <loc>https://example.com/</loc>
  </url>

The root element is not closed.

A corrected example is:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/</loc>
  </url>
</urlset>

B. Verify URL Formatting

Check whether every URL:

  • Uses an absolute URL.
  • Contains the correct domain.
  • Uses the intended HTTPS version.
  • Points to the correct page.
  • Does not contain accidental whitespace.

C. Check HTTP Accessibility

A sitemap should be accessible to search engines.

Check that:

  • The sitemap URL returns a successful response.
  • The server does not require authentication.
  • The file is not accidentally blocked.
  • The content is served in a suitable format.

D. Review URL Quality

A sitemap should contain URLs that website owners want search engines to discover.

Avoid unnecessarily including:

  • Redirecting URLs
  • Broken URLs
  • Duplicate URL variants
  • Pages returning server errors
  • URLs blocked by robots.txt
  • URLs that should not be indexed

A sitemap should not be treated as a list of every URL that happens to exist on a website.

E. Use Online Developer Utilities

For developers who regularly work with website files and technical resources, browser-based utilities can simplify everyday checking tasks.

Explore Tools.QBMFX.com to discover online tools and developer utilities that can support website-related workflows.

Choose a suitable utility for the specific validation task and verify important results against the official Sitemap Protocol and search engine documentation.

7. How to Submit an XML Sitemap to Google Search Console

After creating and validating the sitemap, you can submit its location through Google Search Console.

Follow these steps.

Step 1: Open Google Search Console

Visit:

https://search.google.com/search-console

Sign in and select the correct website property.

Step 2: Open the Sitemaps Section

In the left-hand navigation, find the Sitemaps report.

Step 3: Enter Your Sitemap URL

Enter the sitemap path.

For example:

sitemap.xml

Step 4: Submit the Sitemap

Click the Submit option.

Google will attempt to retrieve and process the sitemap.

Step 5: Review the Processing Status

Check the sitemap report for its status and any reported errors.

A successfully submitted sitemap does not mean all its URLs will automatically be indexed.

Google independently determines whether and when to crawl and index individual pages.

8. How to Add a Sitemap to Robots.txt

Website owners can also declare the sitemap location in robots.txt.

Example:

User-agent: *
Allow: /

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

This provides an additional discovery path for search engines that support sitemap declarations.

If a website uses multiple sitemap files, a sitemap index can be declared instead.

Example:

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

The sitemap location should point to an accessible and valid file.

9. Common XML Sitemap Errors and How to Fix Them

Even well-maintained websites can develop sitemap problems.

Here are some common examples.

A. Invalid XML Syntax

Missing closing tags, incorrect nesting, and invalid characters can cause XML parsing errors.

Solution: Validate the XML document and correct its structure.

B. Including Redirecting URLs

A sitemap may contain URLs that redirect to other pages.

Solution: Prefer the final destination URL when it is the intended canonical page.

C. Including Noindex Pages

Including pages with noindex directives can create inconsistencies between the sitemap and the intended indexing strategy.

Solution: Review sitemap entries and remove URLs that are not intended for indexing.

D. Including Blocked URLs

URLs blocked by robots.txt should generally not be included in a sitemap intended to help search engines discover indexable pages.

Solution: Review the robots.txt configuration and sitemap entries together.

E. Incorrect Lastmod Values

Automatically updating every lastmod date on every build can provide misleading information.

Solution: Use genuine modification dates that reflect meaningful page changes.

F. Exceeding Sitemap Limits

A sitemap must follow the protocol's file-size and URL-count limits.

Solution: Split large sitemaps into multiple files and use a sitemap index.

G. Submitting the Wrong Sitemap URL

A sitemap may be generated correctly but submitted using an outdated or incorrect path.

Solution: Open the sitemap directly in a browser and submit its actual accessible URL.

10. XML Sitemap vs. HTML Sitemap

XML and HTML sitemaps serve different purposes.

Feature XML Sitemap HTML Sitemap
Primary audience Search engine crawlers Website visitors
Format XML HTML
Main purpose URL discovery Website navigation
User visibility Usually not designed for visitors Visible webpage
Typical location /sitemap.xml /site-map/ or /sitemap/

An XML sitemap supports search engine discovery, while an HTML sitemap helps visitors navigate website sections.

A website can use both.

11. Practical XML Sitemap Maintenance Workflow

Maintaining a sitemap is an ongoing technical SEO task.

A practical workflow can include the following steps:

Step 1: Generate a sitemap using your website framework or content management system.

Step 2: Review the URLs included in the file.

Step 3: Validate XML syntax and sitemap structure.

Step 4: Check that important URLs are accessible.

Step 5: Remove inappropriate or outdated entries.

Step 6: Confirm that the sitemap URL is accessible through the website root.

Step 7: Add the sitemap declaration to robots.txt where appropriate.

Step 8: Submit the sitemap through Google Search Console.

Step 9: Review sitemap processing reports and investigate errors.

Step 10: Repeat these checks after major website changes.

For websites that publish content frequently, automated sitemap generation can reduce manual maintenance.

12. Useful Resources for XML Sitemap Development and Validation

The following resources can help developers understand sitemap requirements and maintain technical SEO workflows.

Tools.QBMFX.com

https://tools.qbmfx.com/

Explore browser-based online tools and developer utilities for everyday website management and technical tasks.

Google Search Central: Build and Submit a Sitemap

https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap

Official guidance explaining sitemap creation, formatting, and submission.

Google Search Console

https://search.google.com/search-console

Useful for submitting sitemaps and reviewing their processing status.

Sitemaps.org Protocol

https://www.sitemaps.org/protocol.html

The official Sitemap Protocol specification covering XML structure, URL entries, and sitemap limits.

Astro Sitemap Integration

https://docs.astro.build/en/guides/integrations-guide/sitemap/

Useful for developers building static websites with Astro.

13. XML Sitemap Audit Checklist

Before submitting or updating an XML sitemap, review this checklist:

  • [ ] The sitemap is valid XML.
  • [ ] The root element uses the correct sitemap namespace.
  • [ ] Every URL is an absolute URL.
  • [ ] The URLs use the intended domain and protocol.
  • [ ] Important pages are included.
  • [ ] Redirecting URLs are excluded where appropriate.
  • [ ] Broken URLs are excluded.
  • [ ] Noindex pages are reviewed and excluded where appropriate.
  • [ ] Robots.txt restrictions are checked.
  • [ ] Lastmod dates reflect genuine updates.
  • [ ] Sitemap size and URL limits are respected.
  • [ ] The sitemap is publicly accessible.
  • [ ] Robots.txt references the correct sitemap location.
  • [ ] The sitemap has been submitted through Google Search Console.
  • [ ] Processing errors are reviewed and corrected.

Following this checklist can help maintain a more consistent sitemap configuration.

Conclusion

An XML sitemap is a useful technical SEO resource that helps search engines discover important website URLs.

From creating XML files and generating sitemaps automatically to validating URL entries and submitting them through Google Search Console, every step contributes to maintaining an organized website discovery process.

However, sitemap submission does not guarantee crawling or indexing. Website owners should also maintain proper internal linking, correct canonical references, accessible pages, and appropriate robots directives.

For developers and website owners looking for additional browser-based resources, Tools.QBMFX.com provides an online destination for exploring useful tools and developer utilities.

You can also explore online tools at Tools.QBMFX.com as part of your regular website maintenance and development workflow.

A properly maintained XML sitemap, combined with good technical SEO practices and regular monitoring, can help search engines discover your website content more efficiently.

References

  1. Google Search Central – Build and Submit a Sitemap

    https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap

  2. Google Search Central – Learn About Sitemaps

    https://developers.google.com/search/docs/crawling-indexing/sitemaps/overview

  3. Sitemaps.org – Protocol

    https://www.sitemaps.org/protocol.html

  4. Google Search Console

    https://search.google.com/search-console

  5. Astro – Sitemap Integration

    https://docs.astro.build/en/guides/integrations-guide/sitemap/

  6. Tools.QBMFX.com

    https://tools.qbmfx.com/

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.