A `sitemap.xml` file is an XML document that provides information about the pages on a website. It helps search engines crawl the site more effectively. Below are the key components and structure of a typical `sitemap.xml` file:
- <?xml version="1.0" encoding="UTF-8"?> - Declares the XML version and character encoding.
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap-image/1.1"> - The root element that defines the XML namespace.
- <url> - Contains information about a specific URL on the site.
- <loc> - The location (URL) of the page.
- <lastmod> - The last modified date of the page.
- <changefreq> - How often the page is likely to change (e.g., daily, weekly).
- <priority> - The priority of the page relative to other pages on the site (scale of 0.0 to 1.0).
- </urlset> - Closes the URL set element.
Here is an example of a simple `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>
This structure helps search engines like Google understand the layout and update frequency of your website, improving the chances of better indexing.