A sitemap.xml file is an XML file that lists the URLs for a site along with additional metadata about each URL. This helps search engines like Google to crawl the site more intelligently. Here’s a simple breakdown of a sitemap.xml structure:
- <?xml version="1.0" encoding="UTF-8"?> - Declares the XML version and encoding.
- <urlset> - The root element that contains all the URLs.
-
<url> - A container for each individual URL, which includes:
- <loc> - The URL of the page.
- <lastmod> - The date the page was last modified.
- <changefreq> - The frequency of changes (e.g., daily, weekly).
- <priority> - The priority of the URL compared to other URLs on the site.
- </urlset> - Closes the root element.
Here’s an example of what a simple sitemap.xml might look like:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap-image/1.1">
<url>
<loc>https://www.example.com/</loc>
<lastmod>2023-10-01</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://www.example.com/about</loc>
<lastmod>2023-10-01</lastmod>
<changefreq>yearly</changefreq>
<priority>0.8</priority>