Robots.txt for WordPress: What to Block, What to Leave Alone, and What Breaks
Robots.txt tells crawlers where not to go, it does not remove pages from search. Here is what to block, what to leave alone, and how to check it.
Umair Khan •
What robots.txt does, in plain language
Robots.txt is a plain text file at the root of your site, at yourdomain.com/robots.txt. It tells search engine crawlers which paths they may fetch, and which paths they should not fetch. It controls crawling, not indexing. That distinction is the whole post in one sentence. Blocking a page in robots.txt stops Google from crawling it, but it does not remove it from search. Google can still show a blocked URL in results, with no description, if other pages link to it. If you want a page out of search, use a noindex tag, or remove the page, not robots.txt alone. Robots.txt also does not protect private content. It is a public file, anyone can read it, and a bad bot can ignore it. Never put a secret path in robots.txt and call it protected.
Where robots.txt lives in WordPress
WordPress does not create a physical robots.txt file on a fresh install. It serves a virtual one, built on the fly by WordPress when a request comes in for /robots.txt and no real file exists on disk. The default virtual file is short: User-agent: *, Disallow: /wp-admin/, Allow: /wp-admin/admin-ajax.php. On a public site, WordPress also adds a Sitemap line, pointing at wp-sitemap.xml, or at your SEO plugin sitemap if that plugin replaces it. A physical robots.txt file in your web root overrides all of that, with no warning. The web server finds the real file, serves it, and WordPress never runs. That means the core Allow line for admin-ajax.php, the Sitemap line, and any plugin rules added through the robots_txt filter all stop applying at once, unless you copy them into your physical file yourself. With Rank Math, the editor is at Rank Math SEO, General Settings, Edit robots.txt, in Advanced Mode. Rank Math edits the virtual file, it does not write a physical one. If a physical robots.txt already sits in your site root, the editor locks and shows a notice. Delete or rename that file first, then reload the settings page. What you type in Rank Math replaces the whole file, so include a Sitemap line yourself if you want one. Live check, prospeedguy.com, 27 Nov 2026: this site serves a Rank Math robots.txt, with User-agent *, Disallow /wp-admin/, Allow /wp-admin/admin-ajax.php, Sitemap https://prospeedguy.com/sitemap_index.xml, plus Allow / for GPTBot, ClaudeBot, PerplexityBot, and Google-Extended. That is the file crawlers actually read on this site today.
What to block, and what never to block
Block /wp-admin/, with the Allow line for /wp-admin/admin-ajax.php. The dashboard has no business being crawled, but front-end code calls admin-ajax.php, so blocking the whole admin directory without that exception breaks features that depend on it. Block search result pages, /?s=, if your site creates them. WordPress search URLs are near infinite in variety, low in quality, and they create duplicate content signals. They do not need to be crawled. Never block /wp-content/ or /wp-includes/. Those directories hold the themes, plugins, and uploads that make your pages look like pages: stylesheets, scripts, and images. Google renders your pages with a headless browser before judging them. Block those directories and the renderer gets a page with no CSS and no images, which Google has warned against since 2014. Never block /wp-content/uploads/ if you want your images in Google image results. Robots.txt is the documented way to keep images out, so blocking uploads does exactly that. A sensible starting file for a WordPress blog is: User-agent: *, Disallow: /wp-admin/, Allow: /wp-admin/admin-ajax.php, Disallow: /?s=, Sitemap: https://yourdomain.com/sitemap_index.xml. Replace the sitemap URL with your own. Do not copy a 40 line blocklist from a forum. Most of those lines break rendering or do nothing at all.
Robots.txt vs noindex vs removing a page: which one to use
Use robots.txt when you want to save crawl budget, by keeping crawlers out of paths that create no indexable value, like /wp-admin/ and search result pages. It is a crawling control, not an indexing control. Use noindex when you want a page out of search, but the page itself can stay live. A noindex robots meta tag tells Google not to index that page, while still letting Google crawl it and see the tag. A page blocked in robots.txt cannot be crawled, so Google may never see a noindex tag on it. Use removal when the page should not exist at all. Delete it, or redirect it to a live successor, and let Google recrawl it. A 301 redirect is the right tool for an old URL with a live successor, as we did for the old WordPress HTTPS URL, which now redirects to the current HTTPS post. In short: robots.txt for crawling, noindex for indexing, delete or redirect for removal. Mixing them up is how pages stay in search when you thought you removed them, or disappear from search when you only meant to save crawl budget.
How to check robots.txt in Search Console
Open your site in a browser at yourdomain.com/robots.txt first. That is the file crawlers read. Copy what is there before you edit anything, so you can put it back. In Google Search Console, go to Settings, then the robots.txt report. It shows the file Google last fetched, when it fetched it, and whether any rule is blocking a URL you care about. Google caches robots.txt for up to 24 hours, so a change does not take effect at once, and a test right after saving may still show the old file. Test one URL at a time against the live file. If a page you want indexed is blocked, fix the rule, save, purge any cache in front of the file, and check again after Google refetches it. Do not guess from memory, open the live file.
Common robots.txt mistakes on WordPress
Disallow: / , on a live site. That blocks everything, and it has wiped whole sites from Google overnight. It belongs only on a staging site, and even there, the WordPress Reading setting, Discourage search engines, is the safer way, because since WordPress 5.3 it uses a noindex meta tag on every page instead of Disallow: /. Blocking /wp-content/ or /wp-includes/, as above. It breaks rendering, and it can hurt rankings. Blocking a page and expecting it to disappear from search. Robots.txt does not remove pages, noindex does. Creating a physical file and losing the default rules. The moment a real robots.txt exists, WordPress stops serving its virtual file, and the Allow line for admin-ajax.php and the Sitemap line disappear unless you copy them in. Forgetting the Sitemap line after editing in Rank Math. Rank Math replaces the whole file with what you type, so a Sitemap line has to be in your text, or crawlers lose that pointer. Copying a blocklist that blocks AI crawlers, feeds, trackbacks, and author archives without checking what it breaks. Some of those blocks are harmless, some break rendering or hide content you want found. Add a rule only when you know what it blocks and why.
FAQ
No. Robots.txt controls crawling, not indexing. A blocked page can still appear in search results, with no description, if other pages link to it. Use a noindex tag to keep a page out of search, or delete it and redirect it if it should not exist.
Yes, block /wp-admin/, and allow /wp-admin/admin-ajax.php. The dashboard should not be crawled, but front-end code calls admin-ajax.php, so that exception matters.
Google caches robots.txt for up to 24 hours, so a change takes time to take effect. A blocked page can also be fetched if another rule allows it, or if Google follows a link to it from elsewhere. Check the live file in Search Console, not just the file you saved.
Add a Sitemap line with the full URL of your sitemap index, for example Sitemap: https://yourdomain.com/sitemap_index.xml. If you edit robots.txt in Rank Math, include it yourself, because what you type replaces the whole file.
Copy the current file first, make one change at a time, save, purge any cache in front of the file, then open yourdomain.com/robots.txt in a private window and check it in Search Console. Test the URL you care about against the live file before you move on.



Leave a Reply