Skip to content
24/7 support · 7-day money-back guarantee · Free plan, no card neededSee plans

Blog › WordPress SEO ›

WordPress XML sitemaps and robots.txt: what to include, block and test

Cover image: WordPress XML sitemaps and robots.txt: what to include, block and test

Sitemaps and robots.txt are small files with large consequences. A sitemap tells search engines which URLs you consider important. A robots file tells crawlers where they should not go. Getting them wrong can hide a whole site or waste crawl effort on junk. Getting them right is a one-time setup with occasional checks. This guide explains what each file does, what to include and exclude in WordPress, and how to test.

Contents of the guide: WordPress XML sitemaps and robots.txt: what to include, block and test
The main sections of this guide.

What a sitemap does and does not do

An XML sitemap lists URLs and optionally last modified dates. It helps search engines discover pages, especially on large or new sites with weak internal linking. It is a hint, not a command: listing a URL does not guarantee crawling or indexing, and leaving one out does not prevent it. The best discovery path is still strong internal linking.

What to include

Include indexable, canonical, useful URLs that return a 200 status: pages, posts, products and key categories. Keep the sitemap clean. Exclude noindexed pages, redirected URLs, error pages, parameter variations, thin tag archives and attachment pages. A sitemap full of non-indexable URLs sends mixed signals and makes reports harder to read.

WordPress defaults and SEO plugins

WordPress core generates a basic sitemap at wp-sitemap.xml. Most SEO plugins replace it with their own, giving more control. Use one sitemap source only; disable the others to avoid duplicates. Confirm the sitemap URL, open it in a browser and check that it loads quickly and lists the expected sections. Large sites are split into several files by a sitemap index.

Submit and monitor

Submit the sitemap in Google Search Console and Bing Webmaster Tools. Review the status, the number of discovered URLs and any errors. Compare submitted versus indexed counts in the Pages report. Large gaps point to quality, duplication or crawl issues.

What robots.txt does

The robots file sits at the root of your domain and tells compliant crawlers which paths they may fetch. It controls crawling, not indexing: a blocked URL can still appear in results if other pages link to it, without content. To keep a page out of the index, use a noindex directive on a page that crawlers can fetch, or remove it. Never block a page and also rely on noindex there, because the crawler cannot see the tag.

A sensible WordPress robots file

Keep it simple. Typically you allow everything except the admin area, with an exception for the AJAX endpoint that front-end features use, and you point to your sitemap. Avoid blocking CSS, JavaScript or image folders that are needed to render pages, since search engines need them to understand layout. Do not use robots.txt for security; it is public and does not protect anything.

Common and costly mistakes

  • A leftover disallow-all rule from a staging site that went live.
  • Discouraging search engines in Settings, Reading and forgetting to undo it.
  • Blocking theme or plugin asset folders.
  • Blocking pages you want to be noindexed.
  • Listing the wrong domain, protocol or www variant in the sitemap.
  • Including URLs that redirect.
  • Forgetting to update after a migration.

Handling faceted navigation and parameters

Online shops with filters can generate endless URLs. Control them with canonical tags, noindex where appropriate, internal linking choices and, if necessary, targeted robots rules. Test carefully, because overly broad rules can block good pages.

Test your setup

Use the robots.txt tool to view and test your file and confirm that key URLs are allowed. Use the meta checker to see noindex and canonical tags on sample pages. Run a site audit to find blocked or non-indexable URLs listed in the sitemap. In Search Console, use the URL Inspection tool to see how a specific page was crawled.

Maintenance

Review both files after migrations, redesigns, plugin changes and any time indexed page counts shift unexpectedly. Add them to your monthly checklist.

Frequently asked questions

Do I need a sitemap? Most sites benefit, especially large or new ones.

Does robots.txt remove pages from search? No. Use noindex or removal tools.

How many sitemaps can I have? Multiple, listed in an index file, within size limits.

Why are submitted pages not indexed? Quality, duplication, crawl budget or technical signals; inspect specific URLs.

Should I block AI crawlers? That is a business decision; robots rules can express it, but compliance varies.

Keep reading

Comments

Leave a comment

Check your own site

Run a free audit and see what to fix first.

Run a free audit