What Is robots.txt? A Beginner's Guide

robots.txt is a small text file at the root of a website that tells crawlers — search engines, AI training bots, and others — which parts of the site they're allowed to visit. It's one of the simplest files on any website, and one of the most misunderstood.

Try it now
Open the robots.txt Generator →
Build a robots.txt file in seconds. Presets for allow-all, block-all, or blocking AI training bots.

What robots.txt is

When a crawler arrives at a website, the first thing it does is check for a file called robots.txt at the root of the domain. This file contains rules telling the crawler what it may and may not visit.

It's been part of the web since 1994, when a group of search engine engineers agreed on a common format. Google, Bing, and most other major search engines respect it. The file is a simple, well-defined convention that any site owner can use to communicate their preferences to crawlers.

The file must live at exactly this location:

https://example.com/robots.txt

Not in a subfolder, not at a different path. Only one robots.txt per domain.

What robots.txt is not

This is critical: robots.txt is a request, not a security mechanism.

It does not block access. It does not password-protect anything. It does not stop malicious bots. It relies entirely on the goodwill of the crawler visiting it — like a polite sign at a shop saying "employees only." Most well-behaved crawlers honor it. Bad actors ignore it completely.

Anything you truly need to protect — admin panels, staging environments, internal tools, private files — must be protected with server-side authentication, IP allowlists, or a firewall. robots.txt is not that.

The basic syntax

The file is line-based and simple. Each block starts with a User-agent line, followed by one or more Allow or Disallow rules for that agent.

Allow everything

The default state of the web. Every crawler can visit every page.

User-agent: *
Allow: /

Block everything

Useful for staging sites, development environments, or when you want a site temporarily hidden. Note that this blocks legitimate search engines too, which will remove your site from search results.

User-agent: *
Disallow: /

Block specific folders

Common for admin areas, private sections, or directories you don't want indexed.

User-agent: *
Disallow: /admin/
Disallow: /private/
Disallow: /tmp/

Block specific file types

Often used to keep PDFs or images out of search results, though this doesn't prevent someone from opening the file if they know the URL.

User-agent: *
Disallow: /*.pdf$
Disallow: /*.zip$

Point to your sitemap

You can tell crawlers where to find your sitemap. This doesn't affect crawling directly but helps search engines discover all your pages faster.

Sitemap: https://example.com/sitemap.xml

Blocking AI crawlers

Since around 2023, a growing number of site owners have used robots.txt to block AI training crawlers. These bots operate under different names and are run by different companies. Common ones include:

To block them, list each one with a Disallow: / rule. Here's a full example that allows regular search engines but blocks AI training bots:

# Allow regular search engines
User-agent: *
Allow: /

# Block AI training crawlers
User-agent: GPTBot
Disallow: /

User-agent: ClaudeBot
Disallow: /

User-agent: Google-Extended
Disallow: /

User-agent: CCBot
Disallow: /

User-agent: PerplexityBot
Disallow: /

Sitemap: https://example.com/sitemap.xml

Whether these companies honor the request varies. Google and OpenAI have stated publicly that they respect robots.txt. Other bots are less reliable. Treat any robots.txt-based blocking of AI crawlers as a request rather than a guarantee.

What robots.txt cannot do

A few things people often assume robots.txt does, but doesn't:

The most common robots.txt mistake

Blocking search engines from pages you actually want indexed.

A common scenario: a developer adds Disallow: / to a staging site to keep it out of Google, then forgets to remove it when the site goes live. The site remains completely invisible to search engines for weeks, and by the time someone notices, the domain has lost all its momentum.

Always check https://yourdomain.com/robots.txt after launching a site, and after any deploy that touches the file. Confirm the rules are what you intend.

The other common mistake is using robots.txt to try to remove a page that's already in Google. If a page is already indexed, robots.txt alone won't remove it. You need either a noindex meta tag or a formal removal request through Google Search Console.

Testing your robots.txt

Once your file is live, you can verify it a few ways:

Frequently asked questions

What is robots.txt?
robots.txt is a plain text file placed at the root of a website that tells automated crawlers — search engines, AI training bots, and other bots — which parts of the site they are allowed to access. It's part of the Robots Exclusion Protocol, an informal standard that has been respected by major search engines since the 1990s.
Does robots.txt actually block crawlers?
No, not by itself. robots.txt is a request, not an enforcement mechanism. Legitimate crawlers like Googlebot, Bingbot, and most well-known bots voluntarily obey the file. Malicious scrapers, spam bots, and some AI crawlers ignore it entirely. If you need to actually block access, you must use server-side authentication, IP blocking, or a web application firewall.
Where does robots.txt go?
robots.txt must be placed at the exact root of your domain. For example: https://example.com/robots.txt. It cannot be placed in a subfolder. A robots.txt file in a subdirectory will be ignored by crawlers. Only one robots.txt file is allowed per domain.
How do I block AI crawlers with robots.txt?
AI training bots like GPTBot (OpenAI), ClaudeBot (Anthropic), Google-Extended (Google), CCBot (Common Crawl), and PerplexityBot can each be blocked by name. For example, adding User-agent: GPTBot followed by Disallow: / blocks OpenAI's crawler from your site. Most AI companies publicly document their crawler names and honor robots.txt requests, though enforcement varies.
Does robots.txt affect Google rankings?
Indirectly. If robots.txt prevents Google from crawling a page, that page won't be indexed and can't appear in search results. However, robots.txt itself is not a ranking factor — it only controls access. Blocking Googlebot from pages you want indexed is one of the most common SEO mistakes. Use noindex tags for individual pages you want excluded from search, and reserve robots.txt for broader crawl control.
← Back to Your Online Helper