XML — Sitemap
Basic Sitemap
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2025-01-01</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://example.com/about</loc>
<lastmod>2025-01-01</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
</urlset>
Sitemap Elements
| Element | Description |
|---|---|
| loc | URL location |
| lastmod | Last modification date |
| changefreq | How often it changes |
| priority | Importance (0.0 to 1.0) |
Image Sitemap
<url>
<loc>https://example.com/gallery</loc>
<image:image>
<image:loc>https://example.com/img1.jpg</image:loc>
<image:title>Photo 1</image:title>
</image:image>
</url>
Video Sitemap
<url>
<loc>https://example.com/video</loc>
<video:video>
<video:thumbnail_loc>https://example.com/thumb.jpg</video:thumbnail_loc>
<video:title>My Video</video:title>
</video:video>
</url>
Sitemap Index
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemap1.xml</loc>
<lastmod>2025-01-01</lastmod>
</sitemap>
</sitemapindex>
Mini Practice
- Create a basic sitemap
- Add lastmod and priority
- Create a sitemap index
- Validate the sitemap
Up Next
Continue with File Structure — organizing XML files.
Related Topics
Frequently Asked Questions about Sitemap
What is Sitemap in XML?
Sitemap is a fundamental concept in XML. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Sitemap?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Sitemap.
Why is Sitemap important in XML?
Sitemap is essential for XML development. Understanding this concept will help you write better code and solve real-world problems more effectively.