robots.txt explained in plain English
robots.txt is a small text file that tells search engine bots which parts of your website they may crawl. It is one of the first files Google requests when it visits a site. Getting it right takes two minutes. Getting it wrong can quietly keep your whole site out of search results.
Where it lives
The file must be at the root of your domain:
https://yourdomain.com/robots.txt
A few rules that surprise people:
- It only works at the root. A file at
/blog/robots.txtis ignored. - Each host has its own file.
www.yourdomain.comandshop.yourdomain.comeach need their own. - If the file does not exist, bots assume they may crawl everything. That is fine, but a missing file shows up as an error in some tools, and you lose the chance to point bots at your sitemap.
The simplest good robots.txt
For most small websites this is all you need:
User-agent: *
Allow: /
Sitemap: https://yourdomain.com/sitemap.xml
User-agent: *means “these rules are for every bot”.Allow: /means “you may crawl everything”.- The
Sitemapline tells bots where your list of pages is. It must be a full URL, includinghttps://.
Blocking a folder
To keep bots out of an admin area or a folder of test pages:
User-agent: *
Disallow: /admin/
Disallow: /test/
Sitemap: https://yourdomain.com/sitemap.xml
Paths are matched from the start, so Disallow: /admin/ also covers /admin/settings. Google also understands two wildcards: * for “anything” and $ for “end of the address”. For example, Disallow: /*.pdf$ blocks every PDF.
Rules for one specific bot
You can give different instructions to different bots by name. This is how sites block AI training crawlers while staying in Google Search:
User-agent: GPTBot
Disallow: /
User-agent: Google-Extended
Disallow: /
User-agent: *
Allow: /
GPTBot is OpenAI’s crawler, and Google-Extended controls whether Google may use your content for its AI models. Blocking them does not remove you from normal Google Search, because that uses a different bot called Googlebot.
A bot follows the most specific group that matches its name, and ignores the * group in that case.
The mistakes that hurt
1. Blocking everything by accident
This tiny file hides your entire site from search engines:
User-agent: *
Disallow: /
It is common on staging and development sites, and it sometimes gets copied to the live site at launch. If your new site is not showing up in Google at all, check this first.
2. Thinking Disallow removes a page from Google
Disallow stops crawling, not indexing. If other sites link to a blocked page, Google can still list its address in results, just without a description. To keep a page out of search results, let it be crawled and add this tag to the page instead:
<meta name="robots" content="noindex">
Google has to be able to crawl the page to see that tag, so do not block it in robots.txt as well.
3. Blocking CSS and JavaScript
Old advice said to block folders like /assets/ or /wp-includes/. Today Google renders pages like a browser, so it needs your CSS and JavaScript files. Blocking them can make your pages look broken to Google.
4. Using rules Google ignores
Noindex:inside robots.txt is not supported by Google.Crawl-delay:is ignored by Google, although some other search engines read it.
5. A relative sitemap address
Sitemap: /sitemap.xml is wrong. Use the full address: Sitemap: https://yourdomain.com/sitemap.xml.
Is robots.txt a security feature?
No. It is a polite request, and well-behaved bots follow it. Bad bots ignore it, and anyone can read your robots.txt in a browser. Never list secret folders in it thinking they will be hidden. Protect private areas with a login.
How to check yours
- Open
https://yourdomain.com/robots.txtin your browser. You should see plain text, not an HTML page or an error. - Make sure there is no
Disallow: /underUser-agent: *unless you really mean it. - Check that the sitemap line uses a full
https://address. - In Google Search Console, the robots.txt report shows the version Google last fetched and any problems it found.
Create one in a minute
Our free robots.txt Generator builds a correct file for you. It has safe defaults, presets for common platforms, a sitemap field and one-click options to block AI crawlers. Copy the result, save it as robots.txt and upload it to the root of your site.