SEO and visibility in Google

robots.txt in WordPress — What to Block, What Never to Block, and How to Handle AI Bots

Text
Table of contents

robots.txt is a text file in your site's root directory (twojadomena.pl/robots.txt) that tells search engine crawlers which URLs they shouldn't fetch. It doesn't hide content or remove it from the index — that's what noindex is for. WordPress generates a virtual robots.txt automatically; a correct file for most websites is just a few lines long, and the most common mistakes are blocking CSS/JS and trying to “hide” pages with Disallow.

Thesis: robots.txt is for managing crawl budget, not for hiding pages

Site owners use robots.txt for three things, two of which are wrong:

  1. Blocking unnecessary URLs so Google doesn't waste its time — this is the proper use.
  2. Hiding pages from Google — a mistake. A blocked URL can still be in the index (Google knows it from links), just without its content. For hiding, use noindex.
  3. Blocking “everything that isn't content” — a mistake. Google needs CSS and JS to evaluate the page the way a user sees it; blocked resources hurt your mobile evaluation and Core Web Vitals.

A Correct robots.txt for a Business Website on WordPress

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

Sitemap: https://twojadomena.pl/sitemap_index.xml

That's it. wp-admin blocked, admin-ajax.php unblocked (front-end plugins use it), sitemap specified. Don't block /wp-content/, /wp-includes/, .css files or .js — that's the most common mistake from decade-old tutorials.

Version for a WooCommerce Store

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /koszyk/
Disallow: /zamowienie/
Disallow: /moje-konto/
Disallow: /*?add-to-cart=
Disallow: /*?orderby=
Disallow: /*?filter_

Sitemap: https://twojadomena.pl/sitemap_index.xml

The cart, checkout and account pages have no value for search engines, and “add to cart” links create thousands of useless URLs. Blocking sorting and filter parameters requires caution — more on that below.

What to Block and What Not To — Table

ElementBlock?Why
/wp-admin/YesDashboard — no value for the index
/wp-content/, /wp-includes/NoCSS, JS, images — Google needs them for rendering
Cart, checkout, accountYesTransactional pages with no content
?add-to-cart=, ?orderby=YesEndless duplicates
Filter parameters (?filter_kolor=)Be carefulIf filtered pages have a canonical — don't block, because Google won't see it; if they don't — block
Search pages (?s=)YesEndless number of results
Staging, devNot via robots.txtUse HTTP password protection + noindex; robots.txt doesn't protect anything
PDFs and downloadable filesIt dependsIf you want them to be found, don't block
Thank-you and confirmation pagesnoindex, not DisallowYou want to remove them from the index, and Disallow doesn't do that

Filters are a key issue for online stores — we cover canonical vs. blocking in our article on product filters in WooCommerce.

AI Bots — Block or Not?

Since 2024, robots.txt has had a new use: deciding whether language models can access your content. The most important bots and their purpose:

BotWhoPurpose
GPTBotOpenAIModel training
ChatGPT-UserOpenAIFetching a page when a user asks for it in a conversation
OAI-SearchBotOpenAIChatGPT search — pages ChatGPT can show and cite
ClaudeBotAnthropicTraining and search
Google-ExtendedGoogleGemini training — doesn't affect search or AI Overviews
PerplexityBotPerplexitySearch with citations
CCBotCommon CrawlTraining datasets for many models

Our recommendation for a business website: don't block bots that cite sources. By blocking OAI-SearchBot, ChatGPT-User or PerplexityBot, you cut yourself out of answers in which you could be recommended — and that's the whole point of the strategy we describe in our article on GEO and AI citations. Blocking GPTBot/CCBot (pure training) is a matter of principle — it doesn't change your visibility in search engines.

Important: Google-Extended doesn't control AI Overviews. AI Overviews use the regular Googlebot; blocking it removes your site from search entirely.

How to Edit robots.txt in WordPress

WordPress generates the file virtually. It doesn't physically exist on the server until you create it. There are three ways:

  1. SEO plugin (Yoast, Rank Math): Tools → File editor — the easiest way.
  2. Physical file in the root directory via FTP — overrides the virtual one.
  3. robots_txt filter in the child theme code — for developers.

After every change: test it in Google Search Console (Settings → robots.txt) — it shows how Google reads the file and warns you about syntax errors.

5 Mistakes That Cost You Visibility

  1. Disallow: / left in place after launch – your site will disappear from Google within a few days. Check robots.txt immediately after every site launch.
  2. Blocking /wp-content/ — Google can't see the CSS and rates the page as not mobile-friendly.
  3. Blocking instead of noindex — the page stays in the index as “no information is available for this page because of robots.txt”.
  4. Blocking filter parameters while also using canonical — Google can't read the canonical because it doesn't fetch the page.
  5. Missing Sitemap directive — not critical, but it's a free signal.

A faulty robots.txt is one of the first things we check during an SEO audit — and surprisingly often it's the cause of a “drop nobody can explain”.

From our experience

When we take over websites from other developers, we regularly find robots.txt files with Disallow: /wp-content/ — a relic of tutorials from the days when Google didn't render JavaScript.

FAQ — robots.txt

Does robots.txt hide a page from Google?

No. It blocks fetching the content, but the URL can stay in the index if Google knows it from links. To remove a page from search results, use the noindex tag — and for Google to read it, the page can't be blocked in robots.txt.

Where is robots.txt in WordPress?

At twojadomena.pl/robots.txt. WordPress generates it virtually; you can edit it via an SEO plugin (file editor) or by creating a physical file in the root directory via FTP.

Should you block AI bots in robots.txt?

Bots that cite sources (OAI-SearchBot, ChatGPT-User, PerplexityBot) are worth allowing — thanks to them, your site can be recommended in AI answers. Blocking training bots (GPTBot, CCBot) doesn't affect your search visibility. Google-Extended doesn't control AI Overviews.

Does WooCommerce need a different robots.txt?

Yes — it's worth blocking the cart, checkout, account and the add-to-cart and sorting parameters. Block filter parameters only if the filtered pages have no canonical; otherwise Google won't be able to read the canonical.

Author: Adrian Kamiński — Websky Studio, Poznań. Technical SEO for WordPress websites and stores — we check robots.txt first in every audit.

Your feedback

Was this article helpful?

One click — it helps me choose future topics.

Share this article

Websky Newsletter

New posts straight to your inbox.

Once a month — practical insights on WordPress, WooCommerce, SEO and AI. No spam, unsubscribe with one click.

  • Case studies from Polish projects
  • Checklists and templates to download
  • Google and WordPress changes in a nutshell

Your data goes to Websky Studio only. You can unsubscribe with one click in every message.

SEO & content

Let's find out what's holding back your visibility.

Technical audit, on-page optimization, and keyword monitoring in Senuto. A monthly report, with no "magic" links.

Order an SEO audit