Home / Guides / Technical SEO Foundations

Robots.txt in WordPress: Find It, Edit It, Fix It Safely

Muhammad Younus By Muhammad Younus, WordPress Technical SEO Consultant Updated July 9, 2026 10 min read

Robots.txt is a plain-text file at your domain root that tells search engine crawlers which parts of your site they may visit. WordPress generates a virtual one automatically, which is why you can see yoursite.com/robots.txt in a browser but can't find the file on your server.

One small file, outsized consequences. A good robots.txt steers crawl attention toward the pages that earn you money. A careless one can quietly remove your whole site from Google. This guide covers where the file lives, three safe ways to edit it, what belongs inside, and the mistakes I keep finding in real audits.

What is robots.txt in WordPress?

It's the first thing a crawler requests when it visits your domain: a set of instructions saying which URLs each bot may fetch. It works on the honor system, and the major crawlers, Googlebot, Bingbot, and the AI crawlers, respect it. It is not a security tool and not an index-removal tool; it only controls crawling.

That distinction matters more than any syntax detail: robots.txt controls crawling, not indexing. A blocked URL can still appear in Google if other sites link to it. We'll come back to this, because it's the root of the most damaging mistake on this page.

Where is the robots.txt file in WordPress?

At yoursite.com/robots.txt, always, but here's the part most guides skip: by default there is no actual file. WordPress intercepts the request and generates the response in PHP, on the fly. That's why FTP and file managers show nothing at the root while the browser happily displays content.

The virtual default looks roughly like this:

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

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

Sensible, minimal, and doing nothing for you beyond the basics. The moment you create a physical robots.txt file at the root, or a plugin does, WordPress stops generating the virtual one and your file takes over completely.

How do you edit robots.txt in WordPress?

Three methods, from easiest to most control. Whichever you use, copy your current file somewhere safe first, and test after saving.

  1. Through your SEO plugin. In RankMath: General Settings, then Edit robots.txt. Paste, save, done. The plugin serves your version instead of the WordPress default. Yoast has the equivalent under Tools, File editor.
  2. As a physical file. Create a plain-text file named robots.txt, put your rules in it, and upload it to your site root (the folder holding wp-config.php) via your host's file manager or SFTP. A physical file overrides everything else, including plugins.
  3. With a code filter. For developers who keep configuration in the theme: WordPress applies the robots_txt filter to its virtual output, so a few lines in functions.php or a small plugin can append rules without any file. Useful when the file must stay version-controlled.
One rule owns them all: if a physical file exists, plugins and filters are ignored. When your edits mysteriously don't show up, a forgotten physical file is almost always why.

What should a WordPress robots.txt contain?

The directives are few and the syntax is unforgiving of typos:

DirectiveWhat it doesExample
User-agentNames which bot the following rules apply toUser-agent: Googlebot
DisallowBlocks a path from crawlingDisallow: /wp-admin/
AllowRe-opens a path inside a blocked oneAllow: /wp-admin/admin-ajax.php
SitemapPoints crawlers at your XML sitemapSitemap: https://site.com/sitemap_index.xml

A strong starting point for most WordPress sites:

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /?s=
Disallow: /search/
Disallow: /*?orderby=
Disallow: /*?filter_

Sitemap: https://yoursite.com/sitemap_index.xml

The search and parameter lines are where the real value hides: internal search results and WooCommerce filter URLs multiply into thousands of near-duplicate pages that burn crawl budget. Adjust the parameter patterns to what your own site actually generates, which you can see in Search Console's crawl stats. And never blanket-block /wp-content/: your CSS, JavaScript, and images live there, and Google must render them to evaluate your pages.

Should you block AI crawlers like GPTBot?

Not if you want customers to find you through AI. It's a genuine choice with a real trade-off: blocking GPTBot, ClaudeBot, and PerplexityBot keeps your content out of AI training and answers, and it also keeps your business out of the recommendations those assistants make. For a publisher selling content, blocking can be rational. For a business that wants to be found, it's self-sabotage.

To welcome them explicitly:

User-agent: GPTBot
Allow: /
User-agent: ClaudeBot
Allow: /
User-agent: PerplexityBot
Allow: /
User-agent: Google-Extended
Allow: /

This site runs exactly that policy, paired with an llms.txt file summarizing the business for AI crawlers. Being citable by AI engines is a growing traffic channel, and robots.txt is its front door; the AI search optimization service covers the full setup.

Which robots.txt mistakes kill WordPress rankings?

Robots.txt vs noindex: which one when?

Use robots.txt to manage crawling: keep bots out of infinite parameter spaces, internal search, and admin areas, so crawl budget flows to real pages. Use a noindex meta tag to manage indexing: let Google crawl thin archives or utility pages, read the tag, and drop them from results.

The test is one question: do I need Google to read this page's instructions? Deindexing requires reading, so noindex needs the crawl open. Pure waste, like ten thousand filter combinations, never needs reading, so robots.txt handles it. Getting this pairing right across tags, archives, and WooCommerce URLs is a big part of my crawlability and indexing service, because the two tools misapplied together cause exactly the ghost-listing problem described above.

How do you test robots.txt?

  1. Load it directly. yoursite.com/robots.txt in a browser. It should return your rules instantly, not a 404 or an error page.
  2. Use Search Console's robots.txt report. Under Settings, Google shows the file it currently holds, when it last fetched it, and any parse errors, and lets you request a refetch after changes.
  3. Spot-check specific URLs. Use URL Inspection on a page you intend to keep crawlable. If it reports "blocked by robots.txt," your rules are catching more than you meant, usually a prefix-match surprise.
  4. Watch crawl stats for a week. After a cleanup, Googlebot's fetch distribution should visibly shift away from junk URLs toward content. That shift is the whole point.

Not sure what your robots.txt is doing to your site? It's one of the ten checks in the $49 Health Check, along with the crawl and index checks from the full technical SEO checklist. 48 hours, prioritized fix list, plain English.

Frequently asked questions

Where is robots.txt located in WordPress?

At your domain root: yoursite.com/robots.txt. By default WordPress generates it virtually, meaning no physical file exists on your server until you or a plugin creates one. That's why you can see it in a browser but can't find it in your file manager.

Does every WordPress site need a robots.txt file?

Yes, in practice. WordPress serves a minimal virtual one automatically, so nothing breaks without a custom file, but the default does nothing about crawl budget waste and names no sitemap on older setups. Five minutes of configuration beats the default on any serious site.

Can robots.txt remove a page from Google?

No, and this is the most expensive misunderstanding on this topic. Blocking a crawled page hides its noindex signal, so the URL can stay in the index for months, shown with no description. To remove a page, allow the crawl and use a noindex tag instead.

Should robots.txt block wp-admin?

WordPress already handles this sensibly in its default: it disallows /wp-admin/ while allowing admin-ajax.php, which some themes and plugins legitimately need. Keep that pair exactly as is; blocking admin-ajax.php breaks functionality on many sites.

What happens if my robots.txt has an error?

Depends on the error. An unreachable robots.txt (server error) can make Google pause crawling your whole site as a precaution. A too-broad Disallow silently deindexes sections over time. A syntax typo usually just gets ignored. Test after every change; it takes one minute.

Rather have it done for you?

Skip the DIY. Get it fixed.

The $49 Health Check finds what's actually wrong with your WordPress site in 48 hours, including everything this guide covers.

Get the Health Check See all packages