How to Edit Robots.txt in WordPress: 3 Simple Methods
WordPress serves a virtual robots.txt you won't find in your file manager. Here are three ways to edit it, which one wins, and the mistakes that block Google.
Most WordPress sites never need anyone to touch robots.txt. But when you do need to edit robots.txt in WordPress, it's usually because something is broken: Google can't crawl a section of the site, a staging rule leaked into production, or an SEO plugin and an old file are fighting over the same URL.
Here are the three ways to do it, which one wins when they disagree, and the mistakes I see most often on client sites.
Where Is the Robots.txt File in WordPress?
WordPress builds a virtual robots.txt on the fly whenever someone requests yoursite.com/robots.txt. There's no actual file on your server, which is why you can't find it in your file manager. If a physical robots.txt file exists in your site's root folder, the server sends that file instead and WordPress never runs.
You can see what your site serves right now by opening yoursite.com/robots.txt in a browser. A default WordPress robots.txt looks like this:
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://yoursite.com/wp-sitemap.xml
That default is fine for most small business sites. Only change it when you have a specific reason.
Method 1: Edit Robots.txt in WordPress With Yoast SEO
If you run Yoast, this is the easiest route.
- In your WordPress dashboard, go to Yoast SEO, then Tools.
- Click File editor.
- If you don't have a robots.txt file yet, click Create robots.txt file.
- Make your changes and click Save changes to robots.txt.
One detail matters here. Yoast writes a real, physical robots.txt file to your server. From that point on, the file overrides WordPress's virtual version and any other plugin's robots settings.
If the File editor option is missing, your host has probably turned off file editing in the dashboard. Use Method 3 instead.
Method 2: Edit Robots.txt in WordPress With Rank Math
Rank Math handles it differently, and it's what I run on the client WordPress sites I manage.
- Make sure Rank Math is in Advanced mode (Rank Math, then Dashboard, then the mode toggle at the top).
- Go to Rank Math, then General Settings.
- Click Edit robots.txt.
- Change the rules in the text box and click Save Changes.

Rank Math edits the virtual robots.txt. It stores your rules in the database and serves them through WordPress, with no file written to the server.
That means Rank Math's editor only works if there is no physical robots.txt file. If one exists, Rank Math shows a notice and locks the editor. That notice is your clue that an old file, often left behind by a previous plugin or developer, is overriding everything.
Method 3: Manually Overwrite Robots.txt Over FTP or Your Host's File Manager
This is the method to use when the plugins can't, or when you want full control of your WordPress robots.txt.
- Write your rules in a plain text editor and save the file as robots.txt. Plain text only, no .rtf or .docx.
- Connect to your site with an FTP or SFTP client like FileZilla, or open your host's file manager in cPanel or its own dashboard.
- Open the site's root folder. It's the one that holds wp-config.php and the wp-content folder, usually called public_html.
- Upload robots.txt to that folder, replacing any existing file.
- Open yoursite.com/robots.txt in a private browser window to confirm the new version is live.
A manually uploaded file overrides everything else, including Yoast, Rank Math and WordPress's virtual file. That makes it the most reliable fix. It's also the easiest to forget about two years later, so leave yourself a note.
Which WordPress Robots.txt Wins When They Disagree?
The physical file always wins. If a robots.txt file sits in your root folder, your server sends it, and WordPress, Yoast's settings and Rank Math's editor are all ignored. If no physical file exists, WordPress serves the virtual version, including any rules Rank Math or another plugin added. So when your edits "don't take," check for a physical file first.
The second suspect is caching. If you use Cloudflare or a caching plugin, purge the cache after any change, or the CDN can keep serving the old file until its cache expires.
To see the exact file Google fetched, open Search Console, then Settings, then robots.txt. It lists every version of the file Google crawled and flags any rule it ignored. Mine flagged a Host line, a directive only Yandex ever used, so I deleted it.

What Should You Put in Your WordPress Robots.txt?
For a typical small business WordPress site, keep it close to the default: block the admin area, allow admin-ajax.php, and point to your sitemap. Add rules only to block crawl waste, like internal search results or filter URLs that create thousands of near-duplicate pages.
Robots.txt controls crawling. A noindex tag controls indexing, and a page blocked in robots.txt can still show up in Google. If you want a page out of the results, use a noindex tag and let Google crawl it so it can see the tag. Google's robots.txt documentation is clear on this, and it's the mistake I see most.
Should You Block AI Crawlers in Robots.txt?
You can block AI crawlers like GPTBot (OpenAI), ClaudeBot (Anthropic) and PerplexityBot in robots.txt. For most small businesses, I wouldn't.
Those crawlers are part of how ChatGPT, Claude and Perplexity learn about your business. Block them and you make it harder to show up when someone asks an AI tool for a recommendation in your area. I wrote more about that tradeoff in GEO vs SEO.
If you publish original research or paid content, blocking can make sense. Google-Extended works differently: it only controls whether your content trains Gemini, and Google says blocking it doesn't affect AI Overviews or rankings. For a service business that wants to be found, being readable is the point.
3 Robots.txt Mistakes That Hurt WordPress Sites
These are the ones that show up most in the technical SEO audits I run.
A leftover "Disallow: /" from staging. A developer blocks the whole site while it's being built and forgets to remove the rule at launch. Google stops crawling everything. Check this first if traffic fell off a cliff right after a redesign.
Blocking /wp-content/ or /wp-includes/. Older guides recommended it. Today it stops Google from loading your CSS, JavaScript and images, so it can't render the page properly.
Confusing robots.txt with the "Discourage search engines" box. That setting lives under Settings, then Reading. Modern WordPress uses it to add a noindex tag to every page. Make sure it's unchecked on a live site.
The Takeaway
To edit robots.txt in WordPress, use Yoast's File editor, Rank Math's Edit robots.txt screen, or upload a file manually over FTP. Remember that a physical file overrides everything, and purge your cache after any change.
If you'd rather not guess at this stuff, it's part of what I check in every technical SEO audit. And if your WordPress site has bigger problems than one text file, my guide to scanning WordPress for vulnerabilities is a good next stop.
Want This Applied to Your Business?
Send me your website. I'll audit your marketing for free and write you a 30/60/90 day plan.
Free. No credit card. Takes about a minute.
More Notes
Web DesignThe 4 Types of Augmented Reality and What Each Is Good For
Augmented reality gets discussed as one thing. There are four distinct types with very different costs and use cases, and picking the wrong one is the most common reason AR projects fail.
Web DesignImmersive Web Experiences: When They Help and When They Hurt
Real time 3D in the browser got genuinely good. That does not mean your website should use it. Here is the honest split between immersive web experiences that convert and ones that just cost you loading time.
Web DesignWeb Design Gear: What Actually Matters and What Does Not
I built a desktop at the height of the pandemic and learned that most web design gear advice is about the wrong things. Here is what actually affects the work, in order, and where I wasted money.
Web DesignThe Best Laptops for Writers: 4 Things That Actually Matter
Laptop reviews for writers obsess over benchmarks that do not affect writing at all. After years of writing professionally on a lot of machines, here are the four things that genuinely matter.
