What a robots.txt File Is and Where It Lives
A robots.txt file is a short text file that tells search engine crawlers which parts of your website they may visit. Crawlers are the programs that follow links and read pages. The file is a request, not a lock.1
What it does
Google says a robots.txt file tells search engine crawlers which URLs the crawler can access on your site. It's used mainly to avoid overloading your site with requests.1
An example helps. Say your club site has a page of old test files you don't want crawlers wasting time on. You can ask crawlers to skip that folder. They'll usually skip it.
Notice the word "usually". The next section covers why.
What it can't do
Google states that the instructions in a robots.txt file cannot enforce crawler behavior to your site. It's up to the crawler to obey. Respectable crawlers such as Googlebot do, but other crawlers might not.1
The standard says the same in its own way: these rules are not a form of access authorization.2
So never put private material behind a robots.txt rule and call it safe. A password is the right tool for secrets.1
And robots.txt isn't a way to hide a page from search results either. Why robots.txt Does Not Hide a Page From Search explains what happens.
Where the file goes
The file lives at the root of your site. For a site at www.example.com, the address is www.example.com/robots.txt.3
Google is strict about the spot. The file must be located at the root of the site host it applies to, and it can't sit in a subdirectory such as a folder called pages.3
The file only covers the address it's posted on. Rules at https://example.com/robots.txt apply only to files on that host, and not to a subdomain or a different protocol.3
How to make one
You can write the file in almost any plain text editor. Notepad and TextEdit both work. Google says not to use a word processor, because it can add unexpected characters such as curly quotes that cause problems for crawlers. Save with UTF-8 encoding if you're asked.3
Then upload it to the root of your site. How you do that depends on your hosting. If you aren't sure, ask your hosting company.3
To check it, type your own address followed by /robots.txt into a browser. If you see the contents, the file is public.3
If you use a website builder
On services like Wix or Blogger, you might not need to edit the file directly, or be able to. The service may give you a search settings page instead. Look in its help pages for how it handles page visibility.1
No file at all
Without a file, nothing is blocked. Google says that unless you specify otherwise in your robots.txt file, all files are implicitly allowed for crawling.3 The line-by-line rules are in robots.txt Rules Explained: User-agent, Disallow and Allow.
Cited material
- Robots.txt Introduction and Guide, Google Search Central
- RFC 9309: Robots Exclusion Protocol, IETF
- Create and Submit a robots.txt File, Google Search Central