A sitemap.xml file is an XML file that provides a list of the pages on a website, helping search engines understand the structure of the site. Here's a simple breakdown of its components:
Key Elements of sitemap.xml:
- urlset: The root element that contains all the URLs.
- url: Defines a single URL entry within the sitemap.
- loc: Specifies the location of the URL.
- lastmod: Indicates the last modified date of the URL.
- changefreq: Suggests how frequently the content at the URL is likely to change.
- priority: Indicates the priority of the URL relative to other URLs on the site.
Example of a sitemap.xml:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap-image/1.1">
<url>
<loc>http://www.example.com/</loc>
<lastmod>2023-10-01</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>http://www.example.com/about</loc>
<lastmod>2023-09-15</lastmod>
<changefreq>yearly</changefreq>
<priority>0.8</priority>
</url>
</urlset>
Using a sitemap.xml helps improve SEO by ensuring that search engines can easily discover and index all important pages on your site.