An XML sitemap is a file that lists all the important pages of a website, helping search engines like Google and Bing crawl and index them more efficiently. It provides a structured map of your site's content, ensuring that search engines don’t miss any key pages, especially those that may not be easily discoverable through internal linking.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.example.com/</loc>
<lastmod>2025-02-10</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://www.example.com/blog/</loc>
<lastmod>2025-02-10</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
</urlset>
Creating a sitemap is essential for ensuring that search engines can efficiently crawl and index your website. Here’s a step-by-step guide on how to create an XML sitemap for your website.
You can create an XML sitemap using a text editor like Notepad or VS Code. Below is a basic example :
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.example.com/</loc>
<lastmod>2025-02-10</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://www.example.com/blog/</loc>
<lastmod>2025-02-10</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
</urlset>
sitemap.xml
https://yourwebsite.com/sitemap.xml
).For non-tech users, online tools make sitemap generation easy. Popular tools:
If you’re using WordPress, you can automate sitemap generation.
https://yourwebsite.com/sitemap_index.xml
.yourstore.com/sitemap.xml
.yourwebsite.com/sitemap.xml
.yourwebsite.com/sitemap.xml
.<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.example.com/</loc>
<lastmod>2025-02-10</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://www.example.com/about/</loc>
<lastmod>2025-02-09</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://www.example.com/blog/</loc>
<lastmod>2025-02-08</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
</urlset>
Tag | Description |
---|---|
<urlset> |
The root element that contains all URLs. |
<url> |
Wraps each individual page entry. |
<loc> |
Specifies the URL of the page. |
<lastmod> |
(Optional) Last modified date of the page (Format: YYYY-MM-DD). |
<changefreq> |
(Optional) Suggests how often the page content changes (always , hourly , daily , weekly , monthly , yearly , never ). |
<priority> |
(Optional) A value (0.1 - 1.0) indicating the page’s importance (1.0 = highest priority). |
If you have multiple sitemaps, use a sitemap index file:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://www.example.com/sitemap-pages.xml</loc>
<lastmod>2025-02-10</lastmod>
</sitemap>
<sitemap>
<loc>https://www.example.com/sitemap-blog.xml</loc>
<lastmod>2025-02-09</lastmod>
</sitemap>
<sitemap>
<loc>https://www.example.com/sitemap-products.xml</loc>
<lastmod>2025-02-08</lastmod>
</sitemap>
</sitemapindex>
Sitemaps come in different types, each serving a unique purpose in helping search engines understand and index your website efficiently. Below are the main types of sitemaps:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.example.com/</loc>
<lastmod>2025-02-10</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
</urlset>
<ul>
<li><a href="https://www.example.com/">Home</a></li>
<li><a href="https://www.example.com/blog/">Blog</a></li>
<li><a href="https://www.example.com/contact/">Contact</a></li>
</ul>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url>
<loc>https://www.example.com/video-page/</loc>
<video:video>
<video:thumbnail_loc>https://www.example.com/thumb.jpg</video:thumbnail_loc>
<video:title>My Video</video:title>
<video:description>Watch my awesome video.</video:description>
<video:content_loc>https://www.example.com/video.mp4</video:content_loc>
</video:video>
</url>
</urlset>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>https://www.example.com/gallery/</loc>
<image:image>
<image:loc>https://www.example.com/images/photo1.jpg</image:loc>
<image:title>Beautiful Landscape</image:title>
</image:image>
</url>
</urlset>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
<url>
<loc>https://www.example.com/news/article123.html</loc>
<news:news>
<news:publication>
<news:name>Example News</news:name>
<news:language>en</news:language>
</news:publication>
<news:publication_date>2025-02-10</news:publication_date>
<news:title>Breaking News Headline</news:title>
</news:news>
</url>
</urlset>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0">
<url>
<loc>https://m.example.com/</loc>
<mobile:mobile/>
</url>
</urlset>
m.example.com
).<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://www.example.com/sitemap-pages.xml</loc>
<lastmod>2025-02-12</lastmod>
</sitemap>
<sitemap>
<loc>https://www.example.com/sitemap-videos.xml</loc>
<lastmod>2025-02-10</lastmod>
</sitemap>
</sitemapindex>
An optimized XML sitemap ensures search engines efficiently crawl and index your website, improving your SEO rankings. Follow these best practices to maximize your sitemap’s effectiveness.
* Add pages that you want to be indexed (e.g., landing pages, blog posts, product pages).
* Avoid including noindex pages, duplicate content, or archive pages.
* Automatically update your sitemap whenever you add, delete, or modify pages.
* Use CMS plugins like Yoast SEO (WordPress) or Google XML Sitemaps to automate updates.
* If updating manually, modify the <lastmod>
tag to reflect recent changes.
* Use clean, keyword-rich, and descriptive URLs.
* Stick to a consistent URL format (e.g., always use HTTPS).
* Avoid session IDs and dynamic parameters in URLs.
Example (Good URL vs. Bad URL):
* Good : https://example.com/best-laptops-2025/
* Bad : https://example.com/index.php?id=123&category=tech
Use the <priority>
tag to indicate the importance of pages:
1.0
0.8
0.7
0.5
or lowerExample :
<url>
<loc>https://www.example.com/</loc>
<lastmod>2025-02-10</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
* Add your sitemap to Google Search Console :
https://www.example.com/sitemap.xml
* Submit to Bing Webmaster Tools following a similar process.
* Add the sitemap link in your robots.txt
file:
Sitemap: https://www.example.com/sitemap.xml