On-page and technical checks

Robots.txt for WordPress: a safe default and the mistakes to avoid

How robots.txt works on a WordPress site, a safe default to start from, what not to block, and how to check which crawlers your file lets in.

Setting up robots.txt for WordPress takes one short text file at the root of your site. It tells crawlers which paths they may fetch, and one careless line can keep them away from pages you want found. This guide gives you a safe starting point, explains each line, and shows how to check which crawlers your file lets in.

What robots.txt does, and what it does not

A robots.txt file sits at your site's root, at the address that ends in /robots.txt. It lists the paths crawlers may or may not fetch. Well-behaved crawlers follow it, but it is a request and not a lock, so a crawler that ignores it can still fetch a path.

For the page-level checks that sit alongside this file, read the on-page SEO checklist.

It also does not remove pages from search results. Blocking a page in robots.txt does not remove it from results. A noindex rule on a crawlable page does that, as explained further down.

If a site has no robots.txt at all, Khoji reports that everything is allowed rather than flagging a fault. A missing file is not an error in itself. It is simply a file that says nothing.

Where WordPress keeps robots.txt and how to edit it

WordPress serves a default robots.txt for your site, even if you never created one. To change it, use an SEO plugin that offers a robots.txt editor, or the file manager in your hosting panel. Pick one place to edit it, so you do not end up with two versions that disagree.

A woman uses a laptop and holds a phone behind a fabric shop counter.
Keep a copy of the current robots.txt before editing it.

Follow these steps for every change:

  1. Open your address with /robots.txt added at the end and read what is there now.
  2. Copy the current text into a note on your phone, so you can put it back.
  3. Make the change in the editor your hosting or SEO plugin provides.
  4. Open the address again and confirm the new text shows.

A safe default, explained line by line

Most small WordPress sites can start from a file like this:

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://www.example.org/sitemap_index.xml

Each line does one job:

  • User-agent: * means the rules below apply to every crawler that follows robots.txt.
  • Disallow: /wp-admin/ asks crawlers to skip the admin login area, which has no value in search results.
  • Allow: /wp-admin/admin-ajax.php keeps one file inside that folder open, because some features on the site load content through it.
  • Sitemap points crawlers to the list of pages you want found.

Treat this as a starting point. Your site may need one more line, and a plugin may add its own. Read the file after every change.

What not to block: CSS, JavaScript, images and whole sections by accident

Most robots.txt problems are blocks that were added by accident. Watch for these:

  • Stylesheets and scripts. Crawlers need them to see the page the way a visitor does. A rule that blocks your theme folder can make pages look broken to crawlers.
  • Images. Blocking an image folder asks crawlers not to fetch your pictures, which can keep them out of image results.
  • Everything, by mistake. A line that reads Disallow: / with nothing after the slash blocks the entire site. This can come from a copied example that was meant for a test site.
  • A page you want removed from results. Add a noindex rule to that page and leave it crawlable until the rule has been seen. Blocking it in robots.txt alone can leave it in results.
Check robots.txt for these blocksA checklist of four kinds of block that are often added to robots.txt by accident.Check robots.txt for these blocksStylesheets and scripts, which crawlers need to see thepageImage folders, which can keep pictures out of imageresultsA line that reads Disallow: / with nothing after the slashA page you want removed, blocked only in robots.txtAUTOMIX AI
Watch for these when you edit the file.

AI crawlers: allowing or blocking them is your choice

Your robots.txt can name AI crawlers one by one. Khoji reports whether your file lets in each of nineteen named crawlers, including GPTBot, ClaudeBot and PerplexityBot. Whether to allow them is your decision, and it depends on whether you want your public pages used by those systems.

If you decide to block one, name it on its own line:

User-agent: GPTBot
Disallow: /

This asks that crawler to skip the whole site. Well-behaved crawlers follow the request, but it is not a lock. Write your decision for each crawler down, so the next person who edits the file knows what was intended.

Deciding on an AI crawlerA decision path for whether to allow or block one AI crawler in robots.txt.Deciding on an AI crawlerPick one AI crawler todecide onDo you want that systemto use your public pages?Block it byname, withDisallow: /NoYesAllow it, and write the decisiondownRead the file after everychangeAUTOMIX AI
Whether to allow an AI crawler is your decision, and blocking is a request.

Checking the result, crawler by crawler

After any change, check the file against the crawlers you care about:

An older man reviews a tablet at a wooden desk in a pottery studio.
Check crawler access after changing your robots.txt file.
  1. Run your site through the crawler access check in Khoji. It reports allowed or blocked for each of the nineteen named crawlers.
  2. Compare the result with the decisions you wrote down.
  3. Confirm the search crawlers you rely on are still allowed.
  4. Use the robots.txt checker for a quick look at the file itself.

Khoji's crawl also respects the file. It crawls a site within a bound of 100 pages and depth 4, and it checks robots.txt before every fetch.

Frequently asked questions

Does WordPress create a robots.txt file?

Yes. WordPress serves a default robots.txt file for your site, even if you never created one. You can change that file with an SEO plugin that offers an editor, or with the file manager in your hosting panel. Check which place your site uses before you edit, and keep a copy of the current text so you can go back if something breaks.

What should a WordPress robots.txt contain?

A short file is enough. Most small sites need a rule that keeps the admin area out of search, an exception for the admin-ajax file that some features need, and a line that points to your sitemap. Keep everything else open, and check the result after each change, because one wrong line can block the whole site.

Should I block AI crawlers in robots.txt?

That is your decision, and it depends on whether you want your public pages used by those systems. You can allow or block each crawler by name. Blocking is a request that well-behaved crawlers follow, not a lock. Khoji reports whether your file lets in each named crawler, so you can see what your current file does.

Can robots.txt hide a page from Google?

Not reliably. Blocking a page in robots.txt stops crawling, but it does not remove the page from search results. To keep a page out of results, add a noindex rule on the page and leave the page crawlable, so search engines can read the rule. Then check the page and your crawler access results again.

Run a Khoji SEO analysis on your own site to see which crawlers your robots.txt lets in today. Plans and prices are on the pricing page if you want to compare options before you start.

More in On-page and technical checks

All On-page and technical checks guides · Khoji blog

Run a Khoji SEO analysis on your own site