Your robots.txt file is a set of directions that lets search engines know which pages from your website should be crawled by search engines.
The robots.txt file is often misunderstood by SEOs. It’s not intended to block pages from being indexed. But misused, it can have severe consequences.
Add the wrong instruction and you could unintentionally tell Google to completely remove your website from the search results.
The importance of a properly set up robots.txt file cannot be understated. Learn how to correctly configure your robots.txt file, use it to your advantage, and avoid disaster.
Table of Contents
What is a Robots.txt File?
In simple terms, your robots.txt is a plain text file with instructions for web robots (also known as “spiders” or “bots”) that guides how the site should or shouldn’t be crawled. The robots.txt file is found in the root of the website and can be brought up by appending “robots.txt” on the homepage of a website.
Most major CMS platforms provide ways to edit the robots.txt either through their dashboard or through the use of plugins that don’t require a new text file to be created and saved every time a change is made.
Google, Bing, Yahoo, etc.
All search engines have these spiders that crawl the internet. Most search engine crawlers will respect a robots.txt file, but it’s not a failsafe as some may not. The robots.txt file serves as instructions for crawlers on how they should navigate your site.
If you have a smaller website then the importance of blocking crawlers from areas of your site may not be of concern. If you are operating a large ecommerce website with millions of pages, it is paramount that your robots.txt file be set up to block certain pages from being crawled. Large ecommerce sites tend to use faceted navigation or filters for their product pages. This can create endless amounts of parameterized URLs that do not need to be indexed. This can lead to index bloat as well as crawl budget issues if crawlers need to crawl through millions of parameterized URLs.
The structure of a robots.txt file is straightforward.
Each section consists of a user-agent(s) and a set of directives.
User-agent: (Name of the user-agent)
Disallow: (URL string you would not like to be crawled)
Allow: (URL string you want to be crawled)
Note: Wildcards and characters
Within the User-agents and Directives we can see a wildcard (*) and special characters (#, $). These provide additional information to crawlers about what can and cannot be crawled and we’ll discuss those further down.
The “user-agent” declares the specific crawler. An example calling out Google and Bing would look like this:
Other examples of standard search engine crawlers and their user-agent are:
- Google: Googlebot
- Google Images: Googlebot-Image
- Bing: Bingbot
- Yahoo: Slurp
- Yandex: YandexBot
- Duckduckgo: DuckduckBot
KeyCDN has a more comprehensive list of web crawlers out there.
- User-agents are case-sensitive and need to be entered correctly to make sure that the robots.txt file will properly block any crawlers called out.
- You can define as many user-agents as you like but if a user agent is listed twice, the second listing is the one that will be respected.
- Some search engines, like Google, have multiple user agents that will crawl for different reasons. Some of these user agents include
- Googlebot-News – Google News
- Googlebot-Image/1.0 – Google Images
- Googlebot-Video/1.0 – Google Video
- AdsBot-Google – Google Ads
- With the release of ChatGPT browser extensions some sites are looking to block ChatGPT from scraping their sites to generate answers as they don’t want their information taken with out proper citations. ChatGPT uses the user agent “ChatGPT-User” and can be blocked or allowed to crawl through directives like:
The above example shows how to block ChatGPT from crawling your entire site. If you’d like it to crawl your site you could leave the disallow blank or use the “Allow” directive and list out the areas of your site you’d like ChatGPT to crawl.
Disallow and Allow Directives
Your robots.txt directives command the bots to either “Disallow” or “Allow” crawling of certain sections on your website. The “Disallow” directive tells crawlers that they are not allowed to crawl a specific page or subfolder of your site.
Before you start allowing and disallowing crawlers on your site, make sure you have a proper understanding of your website’s structure and what folders you do and don’t want to be crawled and indexed.
- Don’t look at a robots.txt file as a way to “hide” pages.
- Ensure you’ve selected the right sub-folders for crawling.
Let’s look at a disallow directive in action:
In the example above, we are disallowing the ‘resources’ subfolder. The resources section of the website would be off-limits to robots for crawling.
Using the “Allow” directive lets crawlers know where in the site they can crawl.
Many SEOs get thrown off by the trailing slash “/”. For the robots.txt file, a trailing slash “/” indicates that crawlers can crawl anything that comes afterward. In the case of crawling the entire site, it is more common to leave a blank “Disallow” directive than add a “/” to an “Allow” directive.
So why does the allow directive even matter? Consider a situation where you want an entire subfolder disallowed with the exception of one specific page. The “Allow” directive offers more granular control over crawling.
In the example mentioned above, if you wanted crawlers to be able to crawl a certain resource page the directives would look like this:
Now the crawlers know that they can crawl the single resource page being called out in the directives, but not the entire subfolder.
Pro-tips for directives:
- When setting up the directives for your site, it is common practice to block pages that can include sensitive information.
- For an ecommerce site that could entail the shopping cart and checkout pages
- For a financial site it could be login pages
- For large ecommerce sites it is also common practice to block parameterized URLs from faceted navigation to be blocked to reduce index bloat.
- If you are using Shopify as a CMS it is worth noting that it comes with an out-of-the-box robots.txt file setup that can work for most sites. Until recently, the ability to edit this file was not allowed but is not possible to do.
Beyond the standard Disallow and Allow directives, there are a few more directives that are commonly used by SEOs.
You can include an XML sitemap in the robots.txt file using “Sitemap:” These can be added anywhere but best practice is to place them at the end of the file after all the directives. This would look like:
If you have more than one XML sitemap add the ones you’d like crawled most often or the main Index URL if you have your XML sitemaps grouped together in an index file. Google has stated they will only crawl the first 500kb of a robots.txt file and adding too many XML sitemaps can cause them to make the file too large.
Crawl-delay (Deprecated for Google):
The Crawl-delay directive slows down the speed at which crawlers can crawl through your site. This could be utilized if you have a large site and want to limit the number of requests the crawlers can make to your site. This can eliminate the possibility of a crawler overwhelming your servers with too many requests and potentially crashing your site. This is a very rare occurrence and would require log file audits to fully understand how often crawlers are hitting your website.
Google has stated that they stopped recognizing this directive in 2019 (source) but crawlers like Bing still recognize it.
Using a crawl delay directive would look like this:
This will force the Bingbot to wait 4 seconds between each crawl request on the site.
Robots.txt files employ the use of some special characters that allow for fine-tuning what or who you want crawling your site.
Wondering what that asterisk does in the Robots.txt file? This is known as a wildcard. The wildcard on its own includes ‘everything’. It can be used as the user-agent to include all crawlers or in the directives to designate the entire website or everything that follows a folder in a URL structure like:
This blocks all crawlers from crawling everything in the /my-folder/ category.
In addition to the * wildcard, you can also use a $ wildcard to signify the end of a URL string.
An example of this would be:
This will tell crawlers they cannot crawl any URLs that end with .xls in /folder-name/.
If there are parameter options for the file, like /folder-name/file-name.xls?id=123456, then crawlers would be able to crawl the file. The “$” is not widely used as it can be can confusion about how to use it as well as some crawlers not respecting the directive. There are better ways to do what the “$” does by using the “*” wildcard.
Hashtags “#” can be used to add notes in your robots.txt file.
Similar to programming comments that don’t impact the code, this can be used to leave notes in the file for future human users as crawlers will ignore the notes.
Some companies have taken advantage of this and added fun notes to their robots.txt files.
Noindex and Nofollow (Deprecated)
Remember that confusion around using the robots.txt file for preventing indexing? Well, there used to be a Noindex and Nofollow directive, but Google stopped recognizing the Noindex directive in 2019.
The Nofollow directive was never recognized. Best practice is to use these directives as on-page metatags.
For the sake of understanding how it used to function, these directives would appear as follows:
4 Ways Your Robots.txt Files Can Destroy Your SEO
You’d think that the simple series of commands in a robots.txt file wouldn’t impact SEO performance. This couldn’t be further from the truth.
Even with the simplicity of the file, it can have devastating impacts on a site when implemented incorrectly.
I have seen sites crippled by improperly deploying their robots.txt files.
One site was a large college aggregator site that did not remove the “/” from the disallow directive and Google hit this directive and marked the entire site as blocked by robots.txt.
We corrected the robots.txt file immediately and did everything we could to get Google to crawl the site again, such as resubmitting XML sitemaps and requesting indexing on pages in GSC, but the damage was done. It took over a week before the homepage was crawled and indexed and it was a painfully slow process of getting pages indexed.
After 3 months only 100 of the 200 initial pages had been indexed.
Robots.txt Problem #1: Case-sensitivity
Remember, all parts of the robots.txt file are case-sensitive. Using a capital or lowercase letter where it’s not meant to could result in your directives being ignored.
It is possible that the user agents would not be recognized as they are written with the proper case sensitivity.
Robots.txt Problem #2: Trailing slashes
One mistake that can cripple a website is using the “Disallow” directive and leaving a trailing slash in it like:
This tells crawlers they cannot crawl your website. This is sometimes done when a website is being built without a staging environment to keep the website out of search indexes while it’s being built. When the site goes live, it is imperative to make sure this has been changed to:
This ensures that crawlers can crawl your site. By leaving the “Disallow” directive in you can end up with “Blocked by Robots.txt” errors in GSC and depending on how long you leave it could cause your site to take longer to get indexed.
From previous experience, I have seen clients launch a new site with the site blocked by the robots.txt and it took Google over 2 weeks to start indexing the website, and after 1 month only 60% of the URLs had been indexed.
Robots.txt Problem #3: Conflicting directives
Issues can also arise if there are conflicting rules in place. An example of conflicting rules could look like:
This can be confusing to crawlers and different crawlers may react differently to these directives. Google and Bing will respect the directive with more characters. “/resources/” is 1 more character than “/resources” and would recognize the disallow.
Some crawlers may recognize the first one but leaving it up to crawlers to choose the correct directive is not a wise decision as they may choose incorrectly or they could change how they look at multiple directives and suddenly you have parts of your website being crawled that you didn’t.
Robots.txt Problem #4: Large Files
Another lesser issue is having a robots.txt file over 500kb. Gary Ilyes recently shared that Googlebot stops crawling a robots.txt file at 500kb.
You can check the size of your robots.txt file by going to the “Network” tab in Developer Tools on Chrome or you can use Google’s Robots.txt testing tool.
To see pages being blocked by your robots.txt file simply navigate to the “Pages” report in Google Search Console under indexing.
From there, navigate to the “Blocked by robots.txt” section. In this report, you will see a list of the 1000 most recent URLs that have been blocked by your robots.txt file.
Having URLs appear in this report should not be viewed as a negative as you may have directives calling for certain URLs to not be crawled and indexed.
This can be a common sight on an e-commerce website that uses faceted navigation and has parameterized URLs blocked from being crawled.
By ensuring that you avoid these mistakes you can help your site get crawled and indexed properly and minimize wasted crawl budget on pages you do not want to be crawled and indexed.
A robots.txt file is not going to directly cause your website to rank better and realistically can do more direct damage if implemented improperly. With that in mind, having a properly implemented robots.txt file can help improve the crawling of your site which can improve indexing and that can help your site perform better.
How to Create and Implement a Robots.txt File
There are a few different ways to create and implement a robots.txt file. We will cover manually creating and implementing one on a website as many CMS platforms (like WordPress and Magento) provide plugins that can help you create and implement one. Some CMSs (like Wix) have native robots.txt files out of the box.
- Create a plain text file
Using a text editor (Notepad, TextEdit, BBEdit, etc) create your robots.txt file. An example of a simple robots.txt file that only blocks Bing from crawling the site:
After you have finished adding all your directives to your file, save it as “robots.txt” without the quotes.
- Save The Robots.txt File in The Root Directory of Your Site
After you have created the file upload it to your site using an FTP or your websites control panel. If your site uses subdomains you will need to create and implement a robots.txt file for each subdomain. By implementing the robots.txt file on the root domain it will be accessible on example.com/robots.txt.
Below are some examples of different robots.txt files.
Block all crawlers
Allow all crawlers
Block all crawlers from a subfolder
Block all crawlers from a file
Block all crawlers from parameterized URLs
Robots.txt file creation best practices
We’ve worked through how to create your robots.txt file, using the various user-agents, directives, and wildcard characters. Use these best practices so you’re not sabotaging your site with an unnecessary mistake that’s preventing your site from being crawled:
- When creating your file, ensure that important pages are not blocked from being crawled. This includes the homepage, category pages, and product pages not being blocked from crawling by being included in a “Disallow” directive.
- Make sure that content you do not want to appear in SERPs is being blocked from being crawled. The “Disallow” directive can be used here to block pages that contain private or secure information or parts of a website that does not need to be indexed. It is common to see “checkout” and “cart” pages listed with “Disallow” directives for e-commerce sites as these pages do not need to be indexed.
- When inputting the directives in your file, it is important that all directives use the proper case when it comes to syntax. Improper capitalization can cause errors with your file and return unwanted results with different crawlers.
- The robots.txt file should not be used to try to hide low-quality or spammy files. Along with not using the file to block low-quality content, the robots.txt file should not be the only way you try to stop crawlers from crawling and indexing pages you do not want to be crawled and indexed. Proper on-page SEO can be better in this situation by using “noindex” and “nofollow” tags in the meta robots field on individual pages.
Robots.txt: Simple but Powerful
Attention to detail. That should be your mantra for your robots.txt file. Who would have thought that a few lines in a short non-descript file can have such a massive impact on your organic search traffic and website visibility? Your SEO team cannot afford to implement this incorrectly.
If the file is not monitored properly or ignored, you could wake up one day erased from Google search results. Don’t be the villain of the industry’s next SEO horror story.
Need Technical SEO assistance optimizing your Robots.txt file?
iPullRank offers complete Technical SEO audits as part of a larger holistic SEO strategy. Contact us to schedule a consultation.
- Robots.txt Files: Directives, Examples, and Use Cases - April 14, 2023