Your robots.txt file tells crawlers which parts of your site they may visit. One wrong line can stop Google from crawling your whole website. Here is how to read the file, test it and fix the mistakes that cause the most damage.
Where to find robots.txt
It always lives at the root of the host: https://example.com/robots.txt. Open that address in your browser. Each subdomain needs its own file, so shop.example.com does not use the file from example.com.
How to read it
User-agent: *
Disallow: /admin/
Disallow: /cart
Allow: /admin/help
User-agent: Googlebot
Disallow: /internal-search
Sitemap: https://example.com/sitemap.xmlUser-agentstarts a group of rules for a crawler.*means every crawler.Disallowblocks paths that start with the given value.Allowmakes an exception.- When rules conflict, Google follows the most specific (longest) matching rule.
- Googlebot obeys only the most specific group that names it. In the example, Googlebot follows the
Googlebotgroup and ignores the*group entirely. Sitemaptells crawlers where your XML sitemap lives.
The rules that block Google
| Rule | Effect |
|---|---|
Disallow: / | Blocks the entire site |
Disallow: (empty) | Blocks nothing |
Disallow: /blog | Blocks /blog, /blog/post and also /blog-news |
Disallow: /*? | Blocks every URL with a query string |
Disallow: /*.js$ | Blocks JavaScript files, which can stop Google rendering your pages |
The classic accident is a staging file containing Disallow: / that goes live with the site. If your traffic dropped right after a launch or migration, check this first.
robots.txt blocks crawling, not indexing
A disallowed URL can still appear in Google if other pages link to it. It shows up with no description, and Search Console reports it as “Indexed, though blocked by robots.txt”. To keep a page out of results, allow crawling and use a noindex tag instead. Google has to crawl the page to see the noindex.
How to test whether Google is blocked
- Search Console robots.txt report: under Settings › robots.txt, you can see the version Google last fetched, when it fetched it and any parsing errors.
- URL Inspection: inspect a specific URL. If crawling is not allowed, the result says the page is blocked by robots.txt.
- SEOAlertly: a site check confirms robots.txt is reachable and flags a critical finding if a wildcard or Googlebot group disallows the whole site. It is a basic check: complex
Allowand wildcard rules still deserve a manual review.
Other robots.txt mistakes to fix
- Blocking CSS and JavaScript. Google renders pages like a browser. Blocking the files your layout depends on can make pages look broken or empty to Google.
- Server errors on robots.txt. If the file returns a 5xx error, Google may pause crawling the site until it can read the file again. A 404 is treated as “no restrictions”.
- Wrong location or file type. The file must be at the root, named exactly
robots.txt, and served as plain text. - Using robots.txt to hide private content. The file is public, and anyone can read the paths you list. Protect private areas with a login instead.
- No sitemap line. Add
Sitemap: https://example.com/sitemap.xmlso crawlers can find it.
A safe starting robots.txt
For most small sites, this is enough:
User-agent: *
Disallow: /admin/
Disallow: /cart
Disallow: /checkout
Sitemap: https://example.com/sitemap.xmlReplace the paths with your own private areas, or leave only the Sitemap line if there is nothing to block.
After you fix it
Google usually re-reads robots.txt within about a day. You can ask for a faster refresh from the robots.txt report in Search Console. Then request indexing for your most important pages. If pages are still missing, work through the other reasons a page is not indexed.
