Skip to content
Desirly

SEO & AEO

Robots.txt Explained: What to Block and What Never to Block

What robots.txt does and doesn't do, which parts of a site are sensible to block, which you should never block, and how to build and test the file safely.

DE Desirly Editorial Team Published 5 min read

Cover illustration for the guide "Robots.txt Explained: What to Block and What Never to Block"

Robots.txt is a small text file at the root of your website that tells search engine crawlers which parts of the site they may and may not crawl. Used well, it keeps bots out of admin areas and endless filter pages. Used badly, a single wrong line can hide your whole site from Google. A robots.txt generator gives you a safe starting point, but it's still worth understanding what each line does.

What robots.txt does (and what it doesn't)

It does:

  • Ask well-behaved crawlers not to request certain URLs
  • Point crawlers to your XML sitemap

It doesn't:

  • Remove pages from Google. A blocked URL can still appear in search results, usually without a description, if other pages link to it. To keep a page out of search, let it be crawled and add a noindex tag, or put it behind a password.
  • Protect private content. The file is public. Anyone can read it, so listing a "secret" folder in it actually advertises that folder.
  • Stop bad bots. Scrapers and malicious bots simply ignore it. That's a job for your firewall or server settings.

Google's introduction to robots.txt is the official reference if you want the full detail.

How the file is structured

Here's a typical WordPress robots.txt:

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

Sitemap: https://www.example.co.uk/sitemap_index.xml
  • User-agent says which crawler the group of rules applies to. An asterisk means all crawlers.
  • Disallow gives a path the crawler shouldn't request.
  • Allow carves out an exception inside a disallowed path.
  • Sitemap gives the full address of your XML sitemap.

A few rules worth knowing:

  • The file must sit at the root of your site, such as https://www.example.co.uk/robots.txt. Each subdomain needs its own.
  • Paths are case-sensitive, so /Shop/ and /shop/ are different.
  • When an Allow and a Disallow rule both match a URL, Google follows the more specific (longer) rule.
  • Disallow: with nothing after it allows everything. Disallow: / blocks the entire site.
  • Google ignores the crawl-delay line and doesn't support noindex inside robots.txt.

What it's sensible to block

  • Admin and login areas, such as /wp-admin/ on WordPress (keeping the admin-ajax.php exception).
  • Internal search results pages, which can create thousands of thin, near-duplicate URLs.
  • Basket, checkout and account pages, which have no value in search results.
  • Endless filter and sort combinations, such as ?sort= or ?colour= parameters. Be careful here, and only block patterns you're sure about.
  • Staging or test copies of your site, although password protection is the better option for these.

What you should never block

  • Your CSS and JavaScript files. Google renders pages much like a browser does. If it can't load your styles and scripts, it may misjudge how your pages look and work on mobile.
  • Images you want found, such as product photos.
  • Pages you're trying to remove from search. If you block them, Google can't see the noindex tag that tells it to drop them.
  • Your whole site after launch. A classic mistake is copying a staging site's Disallow: / to the live site, or leaving WordPress's "discourage search engines" setting switched on.
  • Important pages through an over-broad rule. See the example below.
  • Your sitemap.

A worked example: the prefix trap

Rules match from the start of the path. Say you want to stop crawlers visiting printer-friendly copies of your pages, which live under /print/. You write:

Disallow: /print

That also blocks /printing-services/ and /print-on-demand/, because both start with /print. If those are your main service pages, they've just disappeared from crawling. The fix is one character:

Disallow: /print/

Always ask of each Disallow line: "What else starts with this?"

Using a robots.txt generator safely

A generator saves you from typos and gives you a sensible default for your platform.

WordPress

WordPress serves a virtual robots.txt by default that blocks /wp-admin/ but allows admin-ajax.php. SEO plugins let you edit it, and a real robots.txt file uploaded to your site's root folder overrides the virtual one. Our WordPress robots.txt generator builds a clean file including your sitemap line.

Blogger

Blogger's default file blocks /search, which covers label and search pages, and lists your sitemap. You can switch on a custom robots.txt in Blogger's settings under crawlers and indexing, but mistakes there are easy to make and hard to spot. Our Blogger robots.txt generator gives you a safe version to start from.

Shopify

Shopify generates a sensible default. You can customise it through a theme template, but only do so if you know exactly why you need to.

A note on AI crawlers

Some AI companies publish crawler names you can address in robots.txt, such as GPTBot from OpenAI, and Google offers a separate Google-Extended token for its AI training controls. Blocking them is a business choice. It may limit how your content is used, but it may also reduce the chance of your business being cited in AI-generated answers. Our post on what AEO is explains why that visibility is starting to matter.

How to test your file

  1. Open yoursite.co.uk/robots.txt in a browser and read it line by line.
  2. For each Disallow rule, ask whether it could match a page you want found.
  3. In Google Search Console, check the robots.txt report in Settings to see which version Google fetched and whether it found errors.
  4. Use the URL Inspection tool on your key pages and confirm crawling is allowed.
  5. After any change, keep an eye on the Page indexing report for pages listed as "Blocked by robots.txt".

Frequently asked questions

Does every website need a robots.txt file?

Not strictly. Without one, crawlers assume they can crawl everything. Having one with a sitemap line is good practice, and it's the natural partner to the steps in how to create and submit an XML sitemap.

Will blocking a page in robots.txt remove it from Google?

No. It stops crawling, not indexing. Use a noindex tag on a crawlable page, or password protection, to keep a page out of search results.

Can I block bad bots with robots.txt?

Only the polite ones. Bots that ignore the rules need blocking at server or firewall level.

Where should the sitemap line go?

Anywhere in the file, though the end is common. Always use the full address, starting with https://.

If you'd like your robots.txt, sitemap and Search Console checked and set up properly, our sitemap and indexing service covers all three.

This guide is general information, not legal, tax or financial advice. Fees, rules and thresholds change, so check the official source before you act. Spotted something out of date? Tell us and we will review it.

Keep reading

Your cookie choices

We use essential cookies to run this site. With your permission we would also use Google Analytics to see which pages help people. Cookie notice

Settings