Robots.txt
robots.txt controls crawling, not indexing. Learn the rules Google follows, how conflicts are resolved, and the mistakes that hide whole sites.
- Time
- 18 min
- Level
- intermediate
- Reviewed
- 5 November 2026
After this lesson you can
- Write robots.txt rules with wildcards correctly.
- Predict which rule wins when allow and disallow conflict.
- Avoid blocking resources and using robots.txt for de-indexing.
robots.txt is a plain text file at the root of a host that tells crawlers which URLs they may request. It manages crawling. It is not a way to keep pages out of search results.
Syntax
# Comments start with #
User-agent: *
Disallow: /cart
Disallow: /checkout
Disallow: /*?sort=
Allow: /cart/help
User-agent: Googlebot-Image
Disallow: /private-images/
Sitemap: https://example.com/sitemap.xml
Which rule wins
- Which group? A crawler follows the single most specific group whose
User-agentmatches it, and falls back to*. Groups are not combined. If you write aGooglebotgroup, Googlebot ignores the*group completely. - Which rule? Within the group, the rule with the longest matching path wins. On an exact tie, the less restrictive rule (allow) wins.
| Rules | URL | Result |
|---|---|---|
Disallow: /shop, Allow: /shop/sale | /shop/sale/boots | Allowed (longer rule) |
Disallow: /*.pdf$ | /files/price.pdf | Blocked |
Disallow: /*.pdf$ | /files/price.pdf?v=2 | Allowed ($ requires the URL to end there) |
Disallow: /folder, Allow: /folder | /folder/page | Allowed (tie, allow wins) |
When robots.txt itself fails
- 4xx (except 429): Google treats the site as having no restrictions.
- 5xx: Google stops crawling for a while, then uses its last good copy for up to 30 days.
- Redirects: followed for a few hops.
A misconfigured server that returns 500 for robots.txt can pause crawling of the whole site.
Common mistakes
- Launching with the staging rule
Disallow: /. Check robots.txt as part of every launch. - Blocking CSS or JavaScript, so Google cannot render pages properly.
- Using robots.txt to de-index pages, which hides the noindex rule.
- Forgetting that groups do not combine, so a new Googlebot group silently drops the general rules.
- Blocking parameter URLs that carry canonicals, so Google cannot see where they point. For crawl-heavy filters on large sites, blocking is fine. For a few duplicates, canonicals work better.
Platform notes
- PrestaShop: generated in Shop Parameters, then Traffic & SEO. Regenerate after changing friendly URLs or languages, and review the result, which includes many rules.
- Shopify: edit only through the
robots.txt.liquidtemplate. - WordPress: a virtual file that SEO plugins can edit. A physical file in the web root overrides it.
Practice
Read the lesson, pass the quiz and do the exercise to complete it.
Knowledge check
5 questions. Get at least 4 right to pass.
Exercise: Review and test your robots.txt
Open your robots.txt. For each rule, write what it blocks and why it exists. Test five important URLs and five URLs you expect to be blocked, using the SEO-L page inspector (it reports whether robots.txt allows Googlebot) or Search Console's robots.txt report. Check that CSS and JavaScript files are not blocked.
Deliverable: Your robots.txt with a comment for each rule, plus a table of the ten test URLs with the expected and actual result.
Sources
Checked against these sources on 5 November 2026. Next review by 5 May 2027.
- How Google interprets the robots.txt specification (Google Search Central, official)
- How to write and submit a robots.txt file (Google Search Central, official)
- Introduction to robots.txt (Google Search Central, official)
- Block Search indexing with noindex (Google Search Central, official)