A robots.txt file is a small text file that tells search engine crawlers which parts of your website they are allowed to visit.
It sits at the root of your domain and is one of the first things a search engine looks for when it arrives.
Getting it right helps the right pages get crawled, while a mistake can accidentally hide your entire site from search.
This guide explains what a robots.txt file does, when you need one, and how to create a correct file in just a few minutes.
When a crawler like Googlebot visits your site, it checks for a file at yourdomain.com/robots.txt before doing anything else.
That file contains simple rules telling the crawler which folders or pages to skip and where to find your sitemap.
It is important to understand what the file does not do.
A robots.txt file requests that crawlers avoid certain areas, but it is not a security feature and it does not guarantee a page stays out of search results.
It controls crawling, not privacy.
A robots.txt file is built from a few simple directives:
User-agent names the crawler the rules apply to, with an asterisk meaning all crawlers. Disallow tells the crawler not to visit a path.
Allow makes an exception inside a disallowed area. Sitemap points crawlers to your sitemap so they can find every page.
A simple file that allows everything and points to a sitemap looks like a single user-agent line, an empty disallow line, and a sitemap line.
You rarely need anything more complex than that for a small site.
Every site benefits from having one, even if it only points to the sitemap. You will specifically want custom rules when you need to:
Keep crawlers out of admin, cart, or staging areas Stop search engines from wasting time on low-value pages Point all crawlers to your sitemap for faster discovery Set a crawl
delay if your server is under heavy load
If you do not have a robots.txt file at all, most search engines will simply crawl everything they can find, which is fine for many small sites but not ideal once you have pages
you would rather keep out of the index.
You can write a robots.txt file by hand in any text editor, but it is easy to make a small syntax error that blocks more than you intended.
Please share by clicking this button!
Visit our site and see all other available articles!
Free SEO Tools Every Small Business Needs in 2026