How to Generate an XML Sitemap: 3 Proven Methods for 2026

TL;DR

Key Takeaways

Quick Answer: How to Generate an XML Sitemap

An XML sitemap is a structured file that lists all important URLs on your website. Generate one using a plugin like Yoast SEO on WordPress, an online generator for static sites, or custom scripting for enterprise platforms. Submit the sitemap URL to Google Search Console and Bing Webmaster Tools to help search engines discover your content efficiently. There is no single "best" method — your choice depends on your CMS, site size, and technical comfort level.

Table of Contents

What Is an XML Sitemap?

An XML sitemap is a machine-readable file that lists URLs on your website along with optional metadata such as lastmod (last modified date), changefreq (change frequency), and priority. Search engines like Google and Bing use this file to discover pages that might otherwise remain uncrawled. It is not a ranking signal — it is a crawl efficiency tool.

Why File Format Matters

Google supports XML, RSS, mRSS, Atom, and TXT sitemaps. XML is the most flexible because it supports metadata. Use XML unless you are publishing a news site (use mRSS or Atom instead).

Why XML Sitemaps Matter in 2026

In 2026, Google's AI Overviews rely on deep content understanding, but the crawl still starts with URLs. A well-structured XML sitemap ensures Google discovers your cornerstone content before your archive pages. Without a sitemap, Google relies entirely on internal links — which may leave important pages buried behind faceted navigation or pagination.

When a Sitemap Helps Most

When a Sitemap Is Unnecessary

Method 1: WordPress Plugins

WordPress generates XML sitemaps out of the box since version 5.5. However, dedicated SEO plugins offer more control. Yoast SEO and Rank Math are the two most common options. Both generate dynamic sitemaps that update automatically when you publish or unpublish content.

Step-by-Step: Yoast SEO

  1. Install and activate Yoast SEO.
  2. Go to SEOSettingsXML Sitemaps.
  3. Toggle the XML sitemap feature on.
  4. Visit yoursite.com/sitemap_index.xml to verify.
  5. Copy the sitemap URL and submit via Google Search Console.

Expert Tip: Yoast splits your sitemap into multiple files by content type (posts, pages, categories, tags). This is helpful for large sites because each file stays under 50,000 URLs. However, exclude tag archives from your sitemap unless you rely on tag pages for discovery — they often add crawl waste.

Step-by-Step: Rank Math

  1. Install and activate Rank Math.
  2. Go to Rank MathSitemap Settings.
  3. Enable the sitemap module and configure which post types and taxonomies to include.
  4. Visit yoursite.com/sitemap.xml to verify.

Comparison: Rank Math offers more granular control over individual post types. For example, you can include custom post types like "recipes" or "events" while excluding "products" that use faceted parameters.

Method 2: Static Site Generators

Static sites built with Jekyll, Hugo, or Next.js require a different approach. These platforms generate HTML files at build time, so sitemaps must be generated during the same build process.

Jekyll Example

Install the jekyll-sitemap gem. Add it to your Gemfile and _config.yml. Run jekyll build — the plugin automatically creates sitemap.xml in your output directory. The plugin respects your _config.yml settings and excludes files marked as published: false.

Hugo Example

Hugo includes built-in sitemap generation. Set enableRobotsTXT = true and configure your sitemap section in config.toml. By default, Hugo generates sitemap.xml with all pages. You can override change frequency per section using front matter.

Author Insight: Static site sitemaps are static files — they do not update until you rebuild the site. For blogs that publish twice weekly, this is acceptable. For news sites publishing hourly, consider a server-side script that regenerates the sitemap via cron job.

Method 3: Enterprise CMS (Custom XML)

Enterprise platforms like Adobe Experience Manager, Sitecore, or custom-built CMS platforms often lack plug-and-play sitemap plugins. In these cases, you must generate the sitemap programmatically.

Workflow

  1. Query your CMS or database for all published, indexable URLs.
  2. Filter out noindex pages, redirect URLs, and duplicate content.
  3. Output XML conforming to the sitemap protocol: https://www.sitemaps.org/schemas/sitemap/0.9.
  4. If your site exceeds 50,000 URLs, create a sitemap index file referencing multiple sitemap files.
  5. Store the sitemap at yoursite.com/sitemap.xml and set up a cron job to regenerate it daily or hourly.

Important Protocol Rules

Expert Tip: If your site has 200,000 URLs, split them into 4 sitemap files — each grouped logically by content type (e.g., products, blog posts, landing pages, support articles). Create a sitemap index file that references all 4. This makes it easier to troubleshoot coverage issues per section.

Submitting Your Sitemap to Google Search Console

Generating the sitemap is only half the work. Submitting it correctly ensures Google knows where to find it.

Submission Steps

  1. Log into Google Search Console.
  2. Select your property (Domain or URL prefix).
  3. Go to Sitemaps in the left sidebar.
  4. Paste your sitemap URL (e.g., https://yoursite.com/sitemap_index.xml) and click Submit.
  5. Wait 24–48 hours for Google to process it. Check for errors under Coverage.

What to Check After Submission

Common Mistakes When Generating XML Sitemaps

Even experienced teams make these errors. Here are the most frequent ones:

Mistake 1: Including Noindex Pages

If a page has a <meta name="robots" content="noindex"> tag, do not include it in your sitemap. Google ignores conflicting signals like this, but it wastes crawl budget and creates noise in your coverage reports.

Mistake 2: Including URL Parameters Without Canonical Tags

Faceted navigation pages (e.g., /products?color=red&size=large) should not appear in your sitemap unless they serve unique content. If they are in your sitemap, ensure they have a self-referencing canonical tag.

Mistake 3: Using Absolute URLs in the Wrong Protocol

Your sitemap must use the exact protocol (HTTP or HTTPS) that Google should crawl. If your site uses HTTPS, do not include HTTP URLs in your sitemap — Google will see them as different pages and may split crawl budget.

Mistake 4: Forgetting to Update After Content Changes

If you delete a page but do not regenerate the sitemap, Google will request the URL and receive a 404. Over time, this increases your crawl error count. Use dynamic sitemaps or automate regeneration.

The SMARTCHAIN Sitemap Optimization Framework

This three-stage framework helps you generate and maintain a sitemap that aligns with Google's crawl priorities, not just a list of every URL.

Stage 1: Audit

Stage 2: Build

Stage 3: Monitor

When to use this framework: Use it when launching a new site, after a site migration, or when you notice a significant drop in indexed pages. Avoid it for tiny sites with fewer than 200 pages — the overhead is not worth the effort.

How This Applies in Practice

Beginner Website

If you run a small personal blog on WordPress with 50 posts, install Yoast SEO and enable the XML sitemap. That is it. Do not overthink priority or change frequency. Submit the sitemap URL to Google Search Console once. Your main challenge will be remembering to check for errors after major updates or theme changes.

SaaS Website

For a SaaS platform with 500 landing pages, 200 documentation articles, and 10 changelog pages, use a dynamic sitemap generator built into your CMS or framework. Exclude changelog pages — they change frequently but hold minimal search value. Group product pages into one sitemap file and documentation into another. Monitor crawl stats weekly; if Google requests the same changelog page 50 times per day, remove it from your sitemap.

Ecommerce Store

An ecommerce site with 20,000 product variants, 500 category pages, and 100 blog posts presents unique challenges. Do not list every color/size variant in your sitemap. Use canonical URLs pointing to the parent product page. Exclude "out of stock" pages unless you plan to restock soon. Use sitemap indexing to split your file into manageable chunks: products, categories, blog posts, landing pages.

Local Business

A local law firm with 20 practice area pages, 5 location pages, and 30 blog posts should use a WordPress plugin or manual sitemap generation. Include all pages since the total is under 50,000. Ensure your location pages are included. Submit to both Google Search Console and Bing Webmaster Tools. Your main gain here is helping Google discover new blog posts faster, which can improve local SEO when you publish time-sensitive content about local regulations.

Frequently Asked Questions

Should I include every page in my XML sitemap?

No. Only include pages you want Google to index. Exclude thin content, duplicate pages, tag archives, paginated series pages (if they offer no unique content), and noindex pages. Including every page dilutes the crawl priority signal and may cause Google to waste crawl budget on low-value URLs. For most sites, including 60–80% of total pages is realistic — the remaining 20–40% should be filtered out during your audit stage.

Can I generate an XML sitemap for free?

Yes. WordPress includes built-in sitemap generation since version 5.5. Yoast SEO and Rank Math are free and offer more control. For static sites, jekyll-sitemap is free. Online generators like XML-Sitemaps.com work for sites under 500 pages. For enterprise sites, you will likely need custom scripting, but the XML protocol itself is open and free. The only costs involved are developer time if you cannot do it yourself.

Does Google penalize incorrect sitemaps?

No, Google does not impose manual penalties for sitemap errors. However, technical problems in your sitemap can lead to indirect issues. For example, missing sitemaps or high error counts can reduce crawl efficiency, which may delay discovery of new content. If your sitemap consistently includes large numbers of 404 pages, Google may deprioritize crawling your sitemap altogether. Fix errors promptly to maintain crawl trust.

How often should I regenerate my XML sitemap?

Regenerate your sitemap whenever you publish, update, or delete significant content. For WordPress sites with dynamic plugins, this happens automatically. For static sites, regenerate on each build. For enterprise sites, schedule daily regeneration if you publish multiple times per day, or weekly if you publish infrequently. Setting the lastmod date accurately is more important than the regeneration frequency itself.

What is the difference between sitemap_index.xml and sitemap.xml?

A sitemap index file (sitemap_index.xml) is a container that references multiple individual sitemap files. Use it when your site exceeds 50,000 URLs or when you want to organize sitemaps by content type (e.g., posts, products, videos). Google receives the index file, then crawls each referenced sitemap separately. A single sitemap.xml works for sites under 50,000 URLs. For very large sites, the index approach is required.

Do image and video sitemaps require separate files?

Yes, if you want to provide detailed metadata for images and videos. Image sitemaps follow standard XML protocol but include image-specific tags like <image:loc> and <image:caption>. Video sitemaps include tags for <video:title>, <video:description>, and <video:content_loc>. Google supports these for richer indexing, but they are optional. If your site uses standard <img> tags with alt text, Google will discover images from your regular sitemap anyway.

Article Summary

This article explained how to generate an XML sitemap using three methods: WordPress plugins (Yoast SEO, Rank Math), static site generators (Jekyll, Hugo), and enterprise CMS custom scripting. You learned when a sitemap helps, common mistakes to avoid, and how to use the SMARTCHAIN Sitemap Optimization Framework — a three-stage process of Audit, Build, and Monitor. You also saw specific guidance for beginner sites, SaaS platforms, ecommerce stores, and local businesses. The key takeaway: a clean, accurate sitemap improves crawl efficiency but does not directly boost rankings.

Conclusion

Generating an XML sitemap is one of the easiest technical SEO tasks you can complete in under 30 minutes. The real work comes after — auditing what goes into it, monitoring coverage in Google Search Console, and removing errors as they surface. A sitemap is not a set-it-and-forget-it asset. Review it at least monthly, especially after content migrations, site redesigns, or significant changes to your URL structure. If you follow the workflow described here, your crawl efficiency will improve, and Google will discover your best content faster.

Final Expert Tip: If you ever question whether a page belongs in your sitemap, ask: "Will a searcher typing a query be happy landing here?" If the answer is no, remove it.

Recommended Resources

About the Author

The SMARTCHAINE Editorial Team specializes in SEO, AI Search Optimization, GEO (Generative Engine Optimization), AI Overviews, Structured Data, Technical SEO, and search visibility strategies for modern search engines and AI-powered discovery platforms.