A glowing blue android in profile under a starry sky
Willis Web Design / 01 of 08

Home / SEO Tips / Robots.txt Guide

SEO Tips

Robots.txt Guide: Control What Google Crawls

A robots.txt file is a short text file at the root of your website that tells search engine crawlers which addresses they may visit. Used well, it keeps Google away from endless filter pages and spares your server. Used badly, it can hide your whole site. This guide explains Google's own robots.txt rules in plain English.

What A Robots.txt File Does For Each Kind Of File

Google's crawlers read your robots.txt file before they crawl your site. Its main job is to manage crawler traffic so your server is not overloaded and crawlers do not waste time on pages that do not matter. Google is firm that it is not a way of keeping a web page out of search results. The effect depends on the type of file being blocked.

File typeWhat blocking it doesWatch out for
Web pages (HTML, PDF and other readable formats)Saves crawling on unimportant or duplicate pages and reduces loadA blocked page can still appear in results as a bare address with no description
Images, video and audioKeeps those files out of Google's results and manages trafficOther people can still link to the files directly
Resource files (scripts, styles, decorative images)Saves crawling if pages still work without themDo not block files Google needs to understand the page

If your site runs on a hosted system such as Wix or Blogger, you may not be able to edit robots.txt at all. Look for a search or SEO settings page instead, which controls the same thing.

What this means for you: for most business sites the file should be short and mostly permissive. If you want a page out of Google, the right tool is a noindex rule, explained in meta tags and noindex, or the steps in removing pages from Google.

Robots.txt Guide In The SEO Tips Map

Every part of the SEO tips, on one map. The page you are reading is highlighted.

What Robots.txt Cannot Do For Your Website

Google lists three limits worth knowing before you rely on the file.

Not Every Crawler Obeys

The rules are voluntary. Google and other reputable crawlers follow them; others may not. Protect anything sensitive with a password instead.

Crawlers Read It Differently

Different crawlers may understand the syntax in slightly different ways. Check the correct way to address each crawler you care about.

Blocked Is Not Hidden

If other sites link to a blocked address, Google can still index it. Use noindex, a password or a removal request to keep it out.

Google also warns that mixing crawling rules and indexing rules can make them cancel each other out. The classic mistake: blocking a page in robots.txt and adding noindex to it. Google cannot crawl the page, so it never sees the noindex. The page stays in results as a bare address.

Where The File Must Live And Which Addresses It Covers

The file must be called robots.txt (the name is case-sensitive) and sit in the top folder of the site. Google reads it over HTTP, HTTPS or FTP. Crucially, the rules only apply to the exact host, protocol and port where the file lives.

File addressCoversDoes not cover
https://example.com/robots.txtEverything on https://example.com/Other subdomains, the http version, or a non-standard port such as :8181
https://www.example.com/robots.txtOnly www.example.comexample.com without www, or deeper subdomains such as shop.www.example.com
https://example.com/folder/robots.txtNothing: crawlers never look in subfoldersThe whole site
https://example.com:443/robots.txthttps://example.com/ as well, because 443 is the default portOther ports such as :444
A file on an IP addressOnly requests to that IP addressThe domain name, even if it runs on that IP

Web addresses using accented letters count as the same site as their encoded (punycode) version. An FTP file only covers FTP addresses.

What this means for you: if your site answers on both www and non-www, or still on http, each version needs its own file, or better, one version should redirect to the other. That set-up is one of the checks in the search settings part of the launch checklist.

The Four Lines Google Understands

The file is plain text, saved as UTF-8, with one rule per line in the form field: value. Field names are not case-sensitive, but the paths you block are. Anything after a # is a comment. Google reads up to 500 KiB and ignores anything beyond that, so keep it lean; moving blocked content into one folder lets one line do the work of many. Lines Google cannot understand are skipped, including a stray byte order mark at the start.

  • user-agent names the crawler the following rules are for. * means all crawlers.
  • disallow gives a path that must not be crawled. It must start with /; an empty value is ignored.
  • allow gives a path that may be crawled, usually to open a gap inside a blocked folder.
  • sitemap gives the full address of a sitemap or sitemap index. It can be on another host, you can list several, and it applies to every crawler.
# Keep crawlers out of internal search results
User-agent: *
Disallow: /search/
Allow: /search/help/

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

Google does not support other fields. In particular, crawl-delay is ignored. Our sitemaps guide explains the other ways to submit a sitemap.

Which Group Of Rules Each Crawler Follows

Rules sit in groups, each starting with one or more user-agent lines. A crawler follows only one group: the one whose user-agent matches it most specifically. Every other group is ignored, including the general * group. The order of groups in the file does not matter, and version numbers or extra text after the name are ignored, so googlebot/1.2 counts as googlebot.

Take a file with three groups: one for googlebot-news, one for * and one for googlebot. Googlebot News follows the first, even when it is crawling images. Normal Googlebot follows the third. Storebot-Google has no group of its own, so it follows the * group, as does any other crawler. Related crawlers only match a group if they are named in it.

  • Several user-agent lines in a row share the rules that follow.
  • If two groups name the same crawler, Google merges them into one.
  • A specific group is never merged with the * group. If Googlebot has its own group, your general rules do not apply to it.
  • A sitemap line between user-agent lines does not end a group.

What this means for you: adding a Googlebot group to "just allow one folder" can quietly lift every restriction in your general group. Repeat the rules you still need inside the new group. More about Google's crawlers is in the three kinds of Google crawler.

Wildcards And Path Matching In Plain English

Paths are matched from the start of the address and are case-sensitive. Google compares them in their encoded form, so a rule written with a special character matches the same address written with percent codes. Two wildcards are supported: * means any run of characters, and $ means the end of the address.

Rule pathMatchesDoes not match
/The whole siteNothing is left out
/$Only the home pageEvery other address
/fish (same as /fish*)/fish, /fish.html, /fish/salmon.html, /fishheads, /fish.php?id=anything/Fish.asp, /catfish, /?id=fish, /desert/fish
/fish//fish/, /fish/?id=anything, /fish/salmon.htm/fish, /fish.html, /animals/fish/
/*.phpAny address containing .php, including /folder/filename.php?parameters/ and /windows.PHP
/*.php$Addresses ending in .php/filename.php?parameters, /filename.php5
/fish*.php/fish.php, /fishheads/catfish.php?parameters/Fish.PHP

A trailing * adds nothing, so /* is the same as /. The difference between /fish and /fish/ catches a lot of people out: the first also blocks /fishheads.

When Allow And Disallow Rules Disagree

When more than one rule matches an address, Google uses the most specific one, meaning the rule with the longest path. If two matching rules are equally specific, the least restrictive one wins, which means allow.

AddressRulesResult
/pageallow: /p and disallow: /Allowed: /p is longer
/folder/pageallow: /folder and disallow: /folderAllowed: a tie goes to allow
/page.htmallow: /page and disallow: /*.htmBlocked: /*.htm is longer
/page.php5allow: /page and disallow: /*.phAllowed: a tie goes to allow
/ (home page)allow: /$ and disallow: /Allowed: /$ is more specific
/page.htmallow: /$ and disallow: /Blocked: /$ only matches the home page

What this means for you: test any change before you publish it. One misplaced Disallow: / blocks the entire site, and checking the file is part of every technical SEO audit.

Server Errors, Redirects And How Long Google Caches The File

What your server sends back when Google asks for robots.txt matters as much as what is in it.

  1. 01

    Success (2xx)

    Google reads the file as it is. If the server sends an HTML page instead, Google tries to pull rules out of it and ignores the rest.

  2. 02

    Redirects (3xx)

    Google follows at least five redirects, then treats it as missing. Meta refresh and JavaScript redirects are not followed.

  3. 03

    Not Found (4xx)

    Any 4xx except 429 means "no file", so everything may be crawled. Do not use 401 or 403 to limit crawling; it does not work.

  4. 04

    Server Errors (5xx)

    For 12 hours Google stops crawling the site. For up to 30 days it uses the last good copy. After that it carries on as if there were no file if the site works, or keeps holding back if the site is down.

Network problems such as timeouts and dropped connections are treated as server errors. Google normally caches the file for up to 24 hours, longer if it cannot fetch a fresh copy, and a Cache-Control max-age header can change that. The cached copy may be shared between Google's crawlers. Robots.txt does not apply to fetches a person triggers themselves, such as a feed reader, or to crawlers that check for malware.

What this means for you: a robots.txt that sometimes throws server errors can pause crawling of your whole site. Reliable UK web hosting avoids that, and the Googlebot and crawling guide covers what to do when crawling goes wrong.

Blocking Faceted And Endless URLs

Google's own advice on URL structure names the pages most worth blocking: internal search results, calendars and other endless spaces, and the sort and filter addresses that shops and listings pages create. These can multiply into thousands of near-identical URLs that soak up crawling time. Block them for the long term; Google advises against changing robots.txt often to shuffle crawling between sections.

User-agent: *
Disallow: /search
Disallow: /*?sort=
Disallow: /*?filter=
Disallow: /calendar/

Before you block, make sure none of these addresses are pages you actually want found, and that each real page has a clean address of its own. The guide to URL mistakes that create duplicate pages explains how these addresses appear, and the canonical URLs guide covers duplicates you cannot block.

What this means for you: if you run an online shop, this is where robots.txt earns its keep, and it is part of my ecommerce SEO set-up. For the other guides in this series, see the SEO tips map.

Based on Google Search Central documentation: Introduction to robots.txt, How Google interprets the robots.txt specification, URL structure best practices for Google Search, Troubleshoot Google Search crawling errors, Reduce the Google crawl rate. Licensed under CC BY 4.0. Rewritten in plain English by Willis Web Design; last checked 13 October 2026.

Questions

Questions About Robots.txt Guide

Will robots.txt stop a page appearing in Google?

Not reliably. Robots.txt controls crawling, not indexing. If other websites link to a blocked page, Google can still show its address in results, usually with no description. To keep a page out of Google, let it be crawled and add a noindex rule, protect it with a password, or remove it. Blocking it in robots.txt as well would stop Google seeing the noindex at all.

What happens if my website has no robots.txt file?

Nothing bad. If Google asks for the file and gets a 404 or another 4xx error (apart from 429), it assumes there are no restrictions and crawls everything it can find. Many small sites manage fine that way. Even so, a simple file that allows everything and lists your sitemap is good practice, and every site I build has one as standard.

Can I use robots.txt to slow Google down?

No. Google does not support the crawl-delay line, so it is ignored. Using 401 or 403 errors to limit crawling does not work either. If Googlebot is overloading your server in an emergency, the right move is to return 503 or 429 responses for a short time. The Googlebot guide on this site explains how to do that safely without losing pages from the index.

How quickly does Google notice changes to robots.txt?

Google usually caches the file for up to 24 hours, so changes can take about a day to take effect. It can be longer if Google cannot fetch a fresh copy because of timeouts or server errors. A Cache-Control max-age header can also lengthen or shorten that time. If you have unblocked something important, give it a day before checking again in Search Console.

Should I block my CSS and JavaScript files?

Usually not. Google needs your style sheets and scripts to see the page the way a visitor does. Google says you can block resource files only if your pages still make sense without them. Blocking files that the page needs to display properly can make it harder for Google to understand your content, which can hurt how the page performs in search.

Does robots.txt keep private pages secret?

No. The file is public, anyone can read it, and listing a private folder there actually tells people where it is. Well-behaved crawlers follow the rules, but nothing forces other bots to obey. For anything sensitive, such as client areas or staff documents, use proper password protection on the server. Robots.txt is for managing crawler traffic, not for security.

Next step

See where your website stands, free.

Run a free test of your current site, or call me for a straight answer about what you need.