Blog

How to Create a Sitemap for WordPress: Step-by-Step Guide

by Madhavan A • Published: October 17, 2026
How to Create a Sitemap for WordPress: Step-by-Step Guide
Contents
Want a Quick Summary?

Summarize this article instantly with ChatGPT.

Summarize with AI

An XML sitemap is a critical technical blueprint for any WordPress website. It serves as a direct, structured directory that tells search engine crawlers like Googlebot and Bingbot which pages, posts, and media files exist on your domain, which URLs represent authoritative canonical versions, and when content was last updated.

While WordPress includes basic native XML capabilities out of the box, enterprise publishers, e-commerce stores, and high-traffic blogs frequently require enhanced control over taxonomies, update frequencies, and image metadata. Learning how to create a sitemap for WordPress using native features, specialized plugins, and manual verification methods ensures your content is crawled, understood, and indexed efficiently.

Native WordPress Sitemaps vs. SEO Plugin Sitemaps

Since the release of WordPress 5.5, core software automatically generates a basic XML sitemap without requiring third-party tools. However, dedicated SEO plugins offer advanced configuration options that core WordPress lacks:

Feature Dimension WordPress Core Native Sitemap SEO Plugin Sitemap (Rank Math / Yoast)
Default URL Endpoint domain.com/wp-sitemap.xml domain.com/sitemap_index.xml
Plugin Requirement None (built into WordPress core) Requires installing an active SEO plugin
Exclusion Controls Requires PHP code filters in functions.php Toggle checkboxes inside WordPress dashboard
Media & Image Extensions Does not include image tags Includes <image:image> schema metadata
Lastmod Timestamp Support Basic date support Dynamic W3C timestamps based on revisions
URL Splitting Threshold 2,000 URLs per sub-sitemap Configurable (typically 1,000 URLs per file)

Method 1: Using the Native WordPress Core Sitemap

If you prefer a lightweight installation without third-party plugins, you can use WordPress core functionality immediately:

  1. Verify Core Indexing Settings:

    Log into your WordPress admin dashboard. Navigate to Settings > Reading. Ensure the checkbox labeled "Discourage search engines from indexing this site" is unchecked. If this option is enabled, WordPress disables native sitemaps entirely and injects noindex directives.

  2. Access Your Native Endpoint:

    Open an incognito browser tab and navigate to https://www.yourdomain.com/wp-sitemap.xml. WordPress will display an XML index file linking to child sitemaps for posts, pages, and taxonomies (e.g., wp-sitemap-posts-post-1.xml, wp-sitemap-posts-page-1.xml).

  3. Excluding Specific Post Types via PHP:

    If you need to remove private custom post types or specific taxonomies from the native sitemap, add a filter function to your child theme's functions.php file:

    add_filter(
        'wp_sitemaps_post_types',
        function( $post_types ) {
            unset( $post_types['testimonial'] );
            return $post_types;
        }
    );

Method 2: Using the Rank Math SEO Plugin (Recommended)

Rank Math automatically disables the basic native core sitemap and replaces it with a fully customizable, high-performance sitemap index file with media support:

  1. Install and Activate Rank Math:

    Go to Plugins > Add New in your WordPress dashboard. Search for "Rank Math SEO", click Install Now, and select Activate.

  2. Navigate to Sitemap Settings:

    In the WordPress admin sidebar, go to Rank Math > Sitemap Settings.

  3. Configure General Settings:

    Review the primary settings:
    Links Per Sitemap: Keep default at 1,000 URLs to ensure quick server response times.
    Images in Sitemap: Toggle to Enabled to ensure product photography and blog illustrations qualify for Google Images indexation.
    Include Featured Images: Toggle to Enabled.

  4. Configure Post Types and Taxonomies:

    Click on Posts, Pages, and Products in the sub-menu. Ensure "Include in Sitemap" is switched on for primary content.
    Click on Categories and Tags. Include categories if you curate them as landing hubs, but disable tags to prevent duplicate crawl bloat.

  5. Verify Your Live Sitemap:

    Click the sitemap URL displayed at the top of the Rank Math settings page, typically resolving at https://www.yourdomain.com/sitemap_index.xml.

Method 3: Using the Yoast SEO Plugin

Yoast SEO is another widely used option for generating dynamic WordPress sitemaps:

  1. Install and Activate Yoast SEO:

    Go to Plugins > Add New, search for "Yoast SEO", and click Install Now followed by Activate.

  2. Enable XML Sitemaps:

    In the admin sidebar, navigate to Yoast SEO > Settings. Under the General tab, locate Site features. Scroll down to XML sitemaps and ensure the toggle switch is turned on.

  3. Manage Indexable Content Types:

    In the Yoast settings sidebar under Content types:
    Set Show Posts in search results to On.
    Set Show Pages in search results to On.
    Under Categories & tags, disable post formats and unused tags to keep the sitemap clean.

  4. Verify the File:

    Navigate to https://www.yourdomain.com/sitemap_index.xml to confirm that Yoast is rendering the child sitemap tree.

Method 4: Generating Sitemaps for Custom or Headless WordPress

If you run a decoupled WordPress architecture (such as Next.js, Gatsby, or Nuxt consuming the WordPress REST API or WPGraphQL), standard plugin sitemaps hosted on the backend server may fail to reflect the frontend domain URLs.

  • Frontend Route Handlers: In Next.js App Router, build a dynamic route at app/sitemap.xml/route.js that fetches posts via REST API and constructs valid XML pointing to frontend paths.
  • Using External Crawlers: For static exports or decoupled platforms needing an independent baseline, audit and export compliant files using an online sitemap generator, then upload the validated sitemap.xml file directly to your public frontend hosting root.

Step-by-Step Server and robots.txt Integration

Once your sitemap is generated and verified, make sure search engine crawlers find it automatically upon arrival:

  1. Edit Your robots.txt File:

    In WordPress, you can edit this file via Rank Math (General Settings > Edit robots.txt), Yoast (Tools > File editor), or by editing the physical file in your web root via FTP.

  2. Declare Your Master Sitemap Directive:

    Add the absolute URL of your sitemap index at the bottom of the file:

    User-agent: *
    Disallow: /wp-admin/
    Allow: /wp-admin/admin-ajax.php
    
    Sitemap: https://www.yourdomain.com/sitemap_index.xml

     

Submitting Your WordPress Sitemap to Search Consoles

To initiate crawling and track indexing diagnostics, submit your verified endpoint directly to major search engines:

Google Search Console

  1. Log into your Google Search Console property.
  2. Under the Indexing menu on the left, click Sitemaps.
  3. In the "Add a new sitemap" box, type sitemap_index.xml (or wp-sitemap.xml if using native core).
  4. Click Submit and verify that the status reports a green "Success".

Bing Webmaster Tools

  1. Sign into Bing Webmaster Tools and select your verified site.
  2. Click Sitemaps in the left sidebar, then click the blue Submit sitemap button.
  3. Enter the complete absolute URL (e.g., https://www.yourdomain.com/sitemap_index.xml) and submit.

Troubleshooting Common WordPress Sitemap Errors

If your sitemap fails to render or produces errors in Google Search Console, check these frequent issues:

  • Blank Page or XML Parsing Error on Line 1: This is typically caused by a blank line or empty whitespace before the opening <?php tag in your theme's functions.php file or a custom plugin. Remove any trailing or leading whitespace outside PHP tags.
  • 404 Not Found on Sitemap URL: If your sitemap returns a 404 error, navigate to Settings > Permalinks in WordPress and click Save Changes without editing anything. This flushes and regenerates WordPress rewrite rules.
  • Caching Conflicts: Caching plugins (such as WP Rocket, W3 Total Cache, or LiteSpeed Cache) may cache XML feeds as static HTML. Add your sitemap URL paths to the "Never Cache URLs" exclusion list in your caching plugin settings.
  • Memory Exhaustion on Large Sites: If you manage tens of thousands of posts, loading dynamic sitemaps can cause PHP execution timeouts. Reduce the link limit per sitemap to 500 or 1,000 inside your SEO plugin, or increase your server's memory_limit to 256M in wp-config.php.

Maintain Automated Discovery Across Your Site

A properly configured WordPress sitemap establishes a reliable communication bridge with search engines. By selecting the right implementation method, keeping taxonomy archives curated, declaring your file in robots.txt, and monitoring coverage reports inside Google Search Console, you ensure every published post and product page remains visible and accessible to search engine crawlers.

Performance Driven

Looking for Measurable Business Growth?

Partner with BrandStory for end-to-end digital & creative excellence.

Talk to Our Experts
Data-driven ROI solutions
Madhavan A

Madhavan A

Madhavan A is a digital marketing expert with a strong SEO specialisation, bringing 8+ years of hands-on experience in driving organic growth and search visibility. He focuses on building data-driven strategies, optimising content performance, and delivering measurable results across competitive digital landscapes.

Transform Your Digital Growth with BrandStory

From SEO, PPC, social media marketing, and content marketing to website development, branding, and lead generation, BrandStory delivers result-driven digital marketing services in Dubai and across the UAE, helping businesses attract, engage, and convert more customers.

Trusted by 1000+ leading brands in Dubai and globally including:

Client Logo
Client Logo
Client Logo
Client Logo

Related Blogs

How to Create a Sitemap for Wix, Webflow, or Custom Websites
October 17, 2026
How to Create a Sitemap for Wix, Webflow, or Custom Websites

Search engines crawl billions of pages daily by traversing hyperlinks across the web. However, if your website relies ...

How to Create a Sitemap for Shopify: Setup and Submission Guide
October 17, 2026
How to Create a Sitemap for Shopify: Setup and Submission Guide

For e-commerce merchants running stores on Shopify, search engine visibility is directly tied to store revenue. If sea...

How to Find and Fix Broken Links That Hurt Your Sitemap
October 17, 2026
How to Find and Fix Broken Links That Hurt Your Sitemap

An XML sitemap is supposed to represent the definitive inventory of your highest-value, fully functioning web pages. W...

Crawl Budget: How Sitemaps Help Search Engines Crawl Your Site
October 17, 2026
Crawl Budget: How Sitemaps Help Search Engines Crawl Your Site

Every website operates under computing and bandwidth constraints, and search engines like Google and Bing are no excep...

Why Google Is Not Indexing Your Pages (and How a Sitemap Helps)
October 17, 2026
Why Google Is Not Indexing Your Pages (and How a Sitemap Helps)

Publishing high-quality content or launching an e-commerce catalog does not guarantee automatic inclusion in Google se...

Sitemap Couldn’t Fetch or Has Errors: Fix It in Google Search Console
October 17, 2026
Sitemap Couldn’t Fetch or Has Errors: Fix It in Google Search Console

Submitting an XML sitemap to Google Search Console is intended to streamline crawl discovery and establish a direct co...