WordPress robots.txt and XML Sitemap: What to Include, What to Block, and How to Test

T
Tommy
8 min readNov 9, 2026Updated Nov 9, 2026
An open timber farm gate in a hedgerow on a gravel lane, with a closed metal gate visible further along the lane in overcast light

A single misconfigured text file can quietly keep Google away from your entire blog, and most WordPress site owners never think to check it.

Your WordPress robots.txt file sits where SEO performance meets site hygiene. Too permissive, and crawlers waste time on admin screens and internal search results. Too restrictive, and you can hide your best content, or the CSS and JavaScript Google needs to render it. This guide covers the default file, what to block, what never to block, how to set up and submit your XML sitemap, how to test, and the mistakes that cause the most damage.

Quick answer: WordPress generates a virtual robots.txt if no physical file exists. Keep the default /wp-admin/ block, make sure your XML sitemap is listed, never block CSS, JavaScript or uploads, and check the result in Google Search Console after every change.

What robots.txt does (and does not do)

robots.txt is a plain text file in your site's root that tells crawlers which URLs they may request. It follows the Robots Exclusion Protocol, and Google's documentation describes it as a way to manage crawler traffic, not a way to keep a page out of search results.

Two points matter here. First, compliance is voluntary: reputable crawlers follow it, malicious scrapers ignore it, so it is not a security tool. Second, blocking a URL stops crawling, not indexing. A blocked URL that other sites link to can still appear in results, usually with no description. To keep a page out of the index, you need a noindex tag, which crawlers can only read if they are allowed to fetch the page.

The default WordPress robots.txt

If there is no physical robots.txt file in your root directory, WordPress serves a virtual one. Open yourdomain.com/robots.txt and on a recent version you will see something like this:

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php

Sitemap: https://yourdomain.com/wp-sitemap.xml

That is a sensible starting point. It keeps crawlers out of the admin area, allows admin-ajax.php (which many themes and plugins call from the front end), and, since WordPress 5.5, points to the core sitemap. For a small blog, it can be enough. If a physical file exists, it replaces the virtual one entirely, so check for one if edits don't appear.

What to block in robots.txt

Block only what has no search value and can waste crawl budget:

  • /wp-admin/ (with the admin-ajax.php exception), already in the default.
  • Internal search results, such as Disallow: /?s= and Disallow: /search/. They create endless thin URLs.
  • Cart, checkout and account pages on WooCommerce stores: /cart/, /checkout/, /my-account/.
  • Low-value parameter URLs your theme or plugins generate, such as filtered or sorted listings, if you see them eating crawl activity in Search Console.

For tag archives, author pages or thin category pages, prefer noindex over robots.txt. You want Google to crawl them, see the tag, and drop them cleanly.

What you should never block

This is where most damage happens. Older guides recommend Disallow: /wp-includes/ and sometimes /wp-content/. Don't. Google renders pages like a browser, and it needs your theme and plugin CSS and JavaScript to understand layout and content. Never block:

  • /wp-content/uploads/, which holds your images (blocking it removes you from image search).
  • /wp-content/themes/ and /wp-content/plugins/ (the CSS and JS files).
  • /wp-includes/ script and style files.
  • Your own sitemap file.
  • Any page you want ranking, including by accident through a broad pattern like Disallow: /blog, which also blocks /blog-seo-tips/.

The nuclear mistake is Disallow: / under User-agent: *. It blocks the whole site. It usually arrives with a staging copy or a developer's "temporary" setting and gets carried to production.

Setting up your WordPress XML sitemap

An XML sitemap lists the URLs you want crawled and indexed. robots.txt says what to avoid, a sitemap says what matters. You have three common sources, and you should use only one:

SourceTypical sitemap URLNotes
WordPress core/wp-sitemap.xmlOn by default since 5.5, minimal controls
Yoast SEO/sitemap_index.xmlReplaces the core sitemap, respects your noindex settings
Rank Math/sitemap_index.xmlReplaces the core sitemap, per-post-type controls
All in One SEO/sitemap.xmlReplaces the core sitemap

Installing an SEO plugin normally disables the core sitemap and adds its own, so you won't end up with two competing ones. If you are still choosing, see our comparison of Yoast vs Rank Math vs All in One SEO. Whichever you use, visit the sitemap URL, confirm it loads, and check that it lists only canonical, indexable URLs. A sitemap full of noindexed or redirected URLs sends mixed signals.

To edit robots.txt from the dashboard, use Yoast SEO > Tools > File editor or Rank Math SEO > General Settings > Edit robots.txt. It is safer than FTP, but remember the physical-file rule above, and check that a security plugin isn't hiding the editor.

Submitting your sitemap in Google Search Console

  1. Open your property in Google Search Console.
  2. Go to Indexing > Sitemaps.
  3. Enter the sitemap path (for example sitemap_index.xml) and click Submit.
  4. Wait for the status to read Success and check the discovered URL count against what you expect.

Listing the sitemap in robots.txt and submitting it in Search Console are complementary, so do both. Submitting does not guarantee indexing; it only helps discovery. If posts sit in the report as discovered but not indexed, our guide to Crawled - Currently Not Indexed covers the next steps.

How to test your robots.txt

Test every change, however small.

  1. Load it in a browser. Visit yourdomain.com/robots.txt and confirm it shows your latest rules as plain text, with no error page and no HTML.
  2. Check the robots.txt report in Search Console. Go to Settings > Crawling > robots.txt. It shows the file Google last fetched, when it fetched it, and any parsing errors. Google caches the file, often for up to a day, so recent changes may take time to show.
  3. Inspect key URLs. Paste a post and a category page into the URL Inspection tool. The result tells you whether crawling is allowed or blocked by robots.txt.
  4. Test the rendered page. Use the live test in URL Inspection and look at the rendered screenshot and page resources. Missing styling, or resources listed as blocked by robots.txt, usually means blocked CSS or JS.

Note that Google retired its old standalone robots.txt tester, so older tutorials pointing to it are out of date.

A note on AI crawler directives

You can address AI bots with their own User-agent blocks. For example:

User-agent: GPTBot
Disallow: /

User-agent: CCBot
Disallow: /

User-agent: Google-Extended
Disallow: /

These ask OpenAI's training crawler, Common Crawl and Google's AI-training control to stay out. Google-Extended does not affect your Google Search rankings. The trade-off is real: blocking AI crawlers can reduce your chances of being cited in AI answers, so decide by goal. Each vendor also runs separate search or retrieval bots with different names, so check their current documentation before assuming one rule covers everything. For the bigger picture on AI discovery, read llms.txt Explained.

Common mistakes to avoid

  • Leaving "Discourage search engines" ticked. Under Settings > Reading, this box makes WordPress add a noindex signal and a Disallow: / rule. It is easy to forget after a staging launch or redesign, and it is the first thing to check when a new site does not appear in Google.
  • Blocking CSS, JS or uploads. Google cannot render your pages properly, and image traffic disappears.
  • Combining Disallow with noindex. If the page is blocked, Google cannot read the noindex tag. To remove a page from results, allow crawling and use noindex.
  • Using robots.txt for security. The file is public. Listing a secret directory advertises it. Protect sensitive areas with authentication.
  • Forgetting that a physical file overrides everything. If plugin edits do not show, look for a stray robots.txt in the root.
  • Changing URLs without redirects. If you restructure permalinks, your sitemap and blocked paths change too. See WordPress Permalinks and 301 Redirects before you do.
  • Never rechecking after a migration. Re-test robots.txt, sitemap and the Reading setting every time you move hosts, switch themes or launch a redesign.

Frequently asked questions

Does WordPress create a robots.txt file automatically?
Yes. If no physical file exists, WordPress serves a virtual one at /robots.txt. On recent versions it blocks /wp-admin/, allows admin-ajax.php and lists the core sitemap.

How do I add my XML sitemap to robots.txt?
Add a line such as Sitemap: https://yourdomain.com/sitemap_index.xml on its own line. Yoast and Rank Math normally add this for you.

Should I disallow wp-includes?
No. Older guides suggested it, but blocking core scripts and styles can stop Google rendering your pages correctly. Leave it open.

What happens if I accidentally block everything?
Google stops crawling the site, and pages can gradually drop out of results. Fix the file, then check the Search Console robots.txt report and request a recrawl of key pages.

Is robots.txt the same as an XML sitemap?
No. robots.txt tells crawlers what to avoid, and the sitemap tells them what to prioritize. They work together.

Conclusion

Good crawl control comes down to a short list: keep the default admin block, add search and cart paths if relevant, never block CSS, JS or uploads, run one sitemap and submit it, and test after every change. Check Settings > Reading today, open your robots.txt report in Search Console, and make sure the file says what you think it says. For the wider picture, work through our WordPress SEO checklist for content creators.