By SitemapFixer Team
Updated April 2026

XML Sitemap Template: Copy-Paste Examples for Every Site Type

Validate your sitemap freeAnalyze Free

An XML sitemap is a structured file that tells search engines which URLs on your site exist, when they were last updated, and how they relate to each other. Google, Bing, and other crawlers read it directly — so getting the format right matters. A malformed sitemap is silently ignored. This guide provides production-ready XML sitemap templates for every major site type, with namespace declarations, real-world examples, and a breakdown of every tag and attribute. Copy, customize, and validate before submitting.

1. Basic XML Sitemap Template (Minimal Valid)

This is the smallest valid sitemap Google will accept. The XML declaration, the correct namespace, and at least one <url> element containing a <loc> tag — that is all you need. Use this as your starting point for any site. The xmlns attribute is mandatory; without it, Google's sitemap parser may reject the file entirely.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://www.example.com/</loc>
  </url>
  <url>
    <loc>https://www.example.com/about/</loc>
  </url>
  <url>
    <loc>https://www.example.com/contact/</loc>
  </url>
</urlset>

Every URL in <loc> must be absolute (including protocol and domain), must return HTTP 200, and must not be blocked by robots.txt or a noindex directive. Submitting a URL that returns 404 or is disallowed in robots.txt does not cause an error, but Google will report it as a warning in Search Console and will not index the page.

2. Full-Featured Sitemap Template (With lastmod, changefreq, priority)

The Sitemaps 0.9 protocol defines four optional tags beyond <loc>: <lastmod>, <changefreq>, <priority>. Google has publicly stated that changefreq and priority are largely ignored in ranking decisions, but lastmod is actively used to determine whether a page needs to be recrawled. Always set <lastmod> accurately — lying about it (setting it to today's date for every URL every day) trains Googlebot to distrust your sitemap and reduces crawl efficiency.

<?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>2026-04-29</lastmod>
    <changefreq>weekly</changefreq>
    <priority>1.0</priority>
  </url>
  <url>
    <loc>https://www.example.com/blog/how-to-fix-sitemap-errors/</loc>
    <lastmod>2026-03-15</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.8</priority>
  </url>
  <url>
    <loc>https://www.example.com/pricing/</loc>
    <lastmod>2026-04-01</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.9</priority>
  </url>
  <url>
    <loc>https://www.example.com/about/</loc>
    <lastmod>2025-11-20</lastmod>
    <changefreq>yearly</changefreq>
    <priority>0.5</priority>
  </url>
</urlset>

lastmod format: Use W3C Datetime format. For date-only precision use YYYY-MM-DD. For full datetime use YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ. changefreq values: always, hourly, daily, weekly, monthly, yearly, never. priority range: 0.0 to 1.0. The default is 0.5 — only deviate meaningfully for your most and least important pages.

3. Sitemap Index Template (For Large Sites)

When your site exceeds 50,000 URLs or 50 MB, split the content into multiple child sitemaps and reference them from a single sitemap index file. The index file uses a different root element (<sitemapindex>) and lists child sitemaps rather than individual URLs. You submit only the index file URL to Google Search Console. Child sitemaps can be organized by content type, section, date range — whatever makes maintenance easiest for your team.

<?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>2026-04-29</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://www.example.com/sitemap-blog.xml</loc>
    <lastmod>2026-04-29</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://www.example.com/sitemap-products.xml</loc>
    <lastmod>2026-04-28</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://www.example.com/sitemap-images.xml</loc>
    <lastmod>2026-04-20</lastmod>
  </sitemap>
</sitemapindex>

The <lastmod> in a sitemap index entry refers to when the child sitemap file itself was last modified, not when individual URLs within it changed. Keep this accurate — Googlebot uses it to decide which child sitemaps to re-fetch. You cannot nest sitemap index files; only one level of indexing is permitted.

4. Image Sitemap Template Extension

Image sitemaps help Google discover images that are lazy-loaded via JavaScript or embedded in ways the crawler might not catch during its first pass. You extend the standard sitemap namespace with the image namespace and add <image:image> blocks inside each <url> entry. A single URL can declare up to 1,000 images. This is especially valuable for photography sites, e-commerce product galleries, and editorial sites with heavy visual content.

<?xml version="1.0" encoding="UTF-8"?>
<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/mountain-trek/</loc>
    <lastmod>2026-04-10</lastmod>
    <image:image>
      <image:loc>https://www.example.com/images/mountain-trek-summit.jpg</image:loc>
      <image:title>Summit view on the mountain trek</image:title>
      <image:caption>Early morning view from the 4,200m summit during our spring trek</image:caption>
      <image:geo_location>Alps, France</image:geo_location>
      <image:license>https://creativecommons.org/licenses/by/4.0/</image:license>
    </image:image>
    <image:image>
      <image:loc>https://www.example.com/images/mountain-trek-basecamp.jpg</image:loc>
      <image:title>Basecamp setup at 3,100m</image:title>
      <image:caption>Our team setting up camp before the final ascent</image:caption>
    </image:image>
  </url>
</urlset>

Required tag: <image:loc> — the absolute URL of the image. Optional tags: <image:title>, <image:caption>, <image:geo_location>, <image:license>. Image URLs must be on the same domain or a domain verified in Search Console. Omit images served from third-party CDNs unless you have verified that domain.

5. Video Sitemap Template Extension

Video sitemaps use the xmlns:video namespace and provide Google with rich metadata about video content embedded on your pages. Google needs the video metadata to surface your videos in Video Search results and to display video rich results in standard web search. The <video:thumbnail_loc> and <video:title> tags are required; everything else is optional but strongly recommended for eligibility in rich results.

<?xml version="1.0" encoding="UTF-8"?>
<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/tutorials/fix-xml-sitemap/</loc>
    <video:video>
      <video:thumbnail_loc>https://www.example.com/thumbnails/fix-xml-sitemap.jpg</video:thumbnail_loc>
      <video:title>How to Fix XML Sitemap Errors in Under 10 Minutes</video:title>
      <video:description>Step-by-step walkthrough of the most common XML sitemap errors and how to resolve each one using Google Search Console and SitemapFixer.</video:description>
      <video:content_loc>https://www.example.com/videos/fix-xml-sitemap.mp4</video:content_loc>
      <video:player_loc>https://www.example.com/player?v=fix-xml-sitemap</video:player_loc>
      <video:duration>587</video:duration>
      <video:expiration_date>2027-04-29</video:expiration_date>
      <video:rating>4.8</video:rating>
      <video:view_count>14200</video:view_count>
      <video:publication_date>2026-04-01T10:00:00+00:00</video:publication_date>
      <video:family_friendly>yes</video:family_friendly>
      <video:tag>sitemap</video:tag>
      <video:tag>xml sitemap</video:tag>
      <video:tag>seo</video:tag>
      <video:category>SEO</video:category>
      <video:live>no</video:live>
    </video:video>
  </url>
</urlset>

Either <video:content_loc> (direct video file URL) or <video:player_loc> (embed player URL) is required — preferably both. <video:duration> is in seconds. If the video expires, set <video:expiration_date> so Google removes it from results automatically.

6. Google News Sitemap Template

News sitemaps are only for sites approved as Google News publishers. If you are not a verified publisher, submitting a news sitemap has no effect. The news namespace adds publication metadata that Google uses to surface content in the News tab and Top Stories carousel. News sitemaps should contain only articles published within the past 48 hours — Google ignores older entries in the news namespace. Update your news sitemap frequently (ideally within minutes of publication).

<?xml version="1.0" encoding="UTF-8"?>
<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/google-updates-crawl-budget-guidance/</loc>
    <news:news>
      <news:publication>
        <news:name>Example News</news:name>
        <news:language>en</news:language>
      </news:publication>
      <news:publication_date>2026-04-29T08:30:00+00:00</news:publication_date>
      <news:title>Google Updates Crawl Budget Guidance for Large Sites</news:title>
    </news:news>
  </url>
  <url>
    <loc>https://www.example.com/news/bing-webmaster-tools-new-sitemap-reports/</loc>
    <news:news>
      <news:publication>
        <news:name>Example News</news:name>
        <news:language>en</news:language>
      </news:publication>
      <news:publication_date>2026-04-28T14:15:00+00:00</news:publication_date>
      <news:title>Bing Webmaster Tools Adds New Sitemap Error Reports</news:title>
    </news:news>
  </url>
</urlset>

Required tags within <news:news>: <news:publication> (with <news:name> and <news:language>), <news:publication_date>, and <news:title>. The language code must be ISO 639 format (e.g., en, fr, de). Publication name must match your registered Google News publication name exactly.

7. How to Customize the Template for WordPress, Next.js, and Shopify

Most modern platforms generate sitemaps automatically, but you often need to adjust the output to match the templates above. Here is what each platform does by default and how to correct common deviations.

WordPress (Yoast / Rank Math): Both plugins generate valid sitemap XML with the correct namespace. The most common issue is including noindexed pages, draft posts, or paginated author archives in the sitemap. In Yoast, go to SEO → Features and enable Advanced settings, then use the Content Types settings to exclude post types and taxonomies you do not want indexed. In Rank Math, Sitemap → Sitemap Index lets you toggle each post type. Always exclude /wp-admin/, /wp-json/, and attachment pages.

Next.js 13+ (App Router): Use the built-in sitemap.ts file at app/sitemap.ts. Return an array of MetadataRoute.Sitemap objects. Next.js automatically generates valid XML with proper namespaces on build. For dynamic routes (blog posts, products), fetch your URLs from your CMS or database inside the function and map them to sitemap entries:

// app/sitemap.ts
import { MetadataRoute } from 'next';

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
  const posts = await fetchBlogPosts(); // your CMS fetch
  const staticPages = [
    { url: 'https://example.com/', lastModified: new Date(), priority: 1.0 },
    { url: 'https://example.com/about/', lastModified: new Date('2025-11-20'), priority: 0.5 },
    { url: 'https://example.com/pricing/', lastModified: new Date('2026-04-01'), priority: 0.9 },
  ];
  const dynamicPages = posts.map((post) => ({
    url: `https://example.com/blog/${post.slug}/`,
    lastModified: new Date(post.updatedAt),
    priority: 0.8,
  }));
  return [...staticPages, ...dynamicPages];
}

Shopify: Shopify auto-generates /sitemap.xml which is a sitemap index pointing to child sitemaps for pages, products, collections, and blogs. You cannot edit the core sitemap file directly. To exclude a page or product, add a noindex meta tag via the theme's SEO settings or a third-party app. For additional URL types (landing pages built with page builders), use a sitemap app that lets you add custom entries to a supplemental sitemap referenced in the index.

8. Common Mistakes in Sitemap Templates

These are the errors that cause Google to either reject a sitemap file or silently ignore parts of it. Most are invisible in a browser but obvious in a sitemap validator.

Wrong or missing XML declaration. The first line must be <?xml version="1.0" encoding="UTF-8"?>. Any whitespace or BOM (byte-order mark) before it causes a parse error. This is the most common cause of "sitemap could not be read" errors in Search Console.

Missing or incorrect namespace URI. The xmlns attribute on <urlset> must be exactly http://www.sitemaps.org/schemas/sitemap/0.9. Using https:// instead of http://, or omitting it entirely, produces an invalid file.

Relative URLs in <loc>. Every URL must be absolute. /about/ is invalid; https://www.example.com/about/ is correct.

Unescaped special characters. XML requires that ampersands, less-than signs, and other reserved characters are properly escaped. Replace & with &amp;, < with &lt;, > with &gt;. Session or tracking parameters like ?ref=email&campaign=spring must be written as ?ref=email&amp;campaign=spring in the XML.

Including non-canonical URLs. Only include the canonical version of each URL. If /page/ is canonical and /page (no trailing slash) redirects to it, list only /page/. Listing both creates a conflicting signal.

Listing URLs that return non-200 status codes. Every URL in a sitemap should return exactly HTTP 200. Redirects (301, 302), soft 404s, server errors (5xx), and client errors (404) waste crawl budget and generate Search Console warnings. Run your sitemap through SitemapFixer before submitting to catch all of these at once.

Setting lastmod to today's date for all URLs. Dynamically stamping every URL with today's date tells Googlebot every page changed today. Googlebot will recrawl all of them, find most unchanged, and begin discounting your lastmod signals. Only update lastmod when the page content actually changed.

9. How Google Validates a Sitemap Template

When you submit a sitemap to Google Search Console, Google's infrastructure runs several validation passes on the file before it begins using the data. Understanding this pipeline helps you interpret the errors and warnings that appear in the Coverage and Sitemaps reports.

Step 1 — XML parsing. Google fetches the sitemap URL and attempts to parse it as valid XML. Malformed XML (missing closing tags, unescaped characters, BOM issues) stops processing here. You will see "Sitemap could not be read" or "XML parsing errors" in Search Console.

Step 2 — Namespace validation. Google checks that the root element and any extension namespaces are recognized. Unknown root elements and mistyped namespace URIs generate warnings but usually do not halt processing entirely.

Step 3 — URL discovery and deduplication. Google extracts all <loc> values, resolves them to absolute URLs, and deduplicates. URLs that differ only in fragment identifier (#) are treated as the same URL.

Step 4 — Crawlability checks. Google checks each URL against robots.txt. Disallowed URLs are noted as warnings. Google does not crawl or index them but counts them against your sitemap's URL limit.

Step 5 — HTTP status and redirect resolution. Googlebot fetches each URL and records its status. Redirects are followed up to a chain limit; the final URL is what gets indexed. 4xx and 5xx URLs are flagged as errors in Search Console under Indexing → Pages.

You can replicate steps 1–3 yourself using the free SitemapFixer validator, which parses your sitemap, validates the namespace, checks for URL issues, and reports the HTTP status of each entry — the same checks Google runs.

Related Guides

Check your sitemap against every template rule
Free analysis in 60 seconds
Analyze My Site Free
Related guides