{"id":124203,"date":"2022-03-28T17:11:52","date_gmt":"2022-03-29T00:11:52","guid":{"rendered":"https:\/\/www.bruceclay.com\/?p=124203"},"modified":"2023-08-07T12:44:12","modified_gmt":"2023-08-07T19:44:12","slug":"robots-txt-guide","status":"publish","type":"post","link":"https:\/\/www.bruceclay.com\/blog\/robots-txt-guide\/","title":{"rendered":"What Is robots.txt? A Beginner\u2019s Guide to Nailing It with Examples"},"content":{"rendered":"
<\/a> In this article, I will explain why every website needs a robots.txt and how to create one (without causing problems for SEO). I\u2019ll answer common FAQs and include examples of how to execute it properly for your website. I\u2019ll also give you a downloadable guide that covers all the details.<\/p>\n Contents:<\/p>\n Robots.txt is a text file that website publishers create and save at the root of their website. Its purpose is to tell automated web crawlers, such as search engine bots which pages not to crawl on the website. This is also known as robots exclusion protocol.<\/p>\n Robots.txt does not guarantee that excluded URLs won\u2019t be indexed for search. That\u2019s because search engine spiders can still find out those pages exist via other webpages that are linking to them. Or, the pages may still be indexed from the past (more on that later).<\/p>\n Robots.txt also does not absolutely guarantee a bot won\u2019t crawl an excluded page, since this is a voluntary system. It would be rare for major search engine bots not to adhere to your directives. But others that are bad web robots, like spambots, malware, and spyware, often do not follow orders.<\/p>\n Remember, the robots.txt file is publicly accessible. You can just add \/robots.txt to the end of a domain URL to see its robots.txt file (like ours here<\/a>). So do not include any files or folders that may include business-critical information. And do not rely on the robots.txt file to protect private or sensitive data from search engines.<\/p>\n OK, with those caveats out of the way, let\u2019s go on\u2026<\/p>\n Search engine bots have the directive to crawl and index webpages. With a robots.txt file, you can selectively exclude pages, directories, or the entire site from being crawled.<\/p>\n This can be handy in many different situations. Here are some situations you\u2019ll want to use your robots.txt:<\/p>\n *Using robots.txt to block off unnecessary crawling is one way to reduce the strain on your server and help bots more efficiently find your good content. Google provides a handy chart here<\/a>. Also, Bing supports the crawl-delay directive, which can help to prevent too many requests and avoid overwhelming the server.<\/p>\n Of course, there are many applications of robots.txt, and I\u2019ll outline more of them in this article.<\/p>\n Every website should have a robots.txt file, even if it is blank. When search engine bots come to your website, the first thing they look for is a robots.txt file.<\/p>\n If none exists, then the spiders are served a 404 (not found) error. Although Google says that Googlebot can go on and crawl the site even if there\u2019s no robots.txt file, we believe that it is better to have the first file that a bot requests load rather than produce a 404 error.<\/p>\n This simple little file can cause problems for SEO if you\u2019re not careful. Here are a couple of situations to watch out for.<\/p>\n This gotcha happens more often than you\u2019d think. Developers can use robots.txt to hide a new or redesigned section of the site while they\u2019re developing it, but then forget to unblock<\/em> it after launch. If it\u2019s an existing site, this mistake can cause search engine rankings to suddenly tank.<\/p>\n It\u2019s handy to be able to turn off crawling while you\u2019re preparing a new site or site section for launch. Just remember to change that command in your robots.txt when the site goes live.<\/p>\n Blocking in robots.txt pages that are indexed causes them to be stuck in Google\u2019s index.<\/p>\n If you exclude pages that are already in the search engine\u2019s index, they\u2019ll stay there. In order to actually remove them from the index, you should set a meta robots “noindex” tag on the pages themselves and let Google crawl and process that. Once the pages are dropped from the index, then block them in robots.txt to prevent Google from requesting them in the future.<\/p>\n To create a robots.txt file, you can use a simple application like Notepad or TextEdit. Save it with the filename robots.txt<\/strong> and upload it to the root of your website as www.domain.com\/robots.txt \u2014\u2014 this is where spiders will look for it.<\/p>\n A simple robots.txt file would look something like this:<\/p>\n User-agent: *<\/span> Google gives a good explanation of what the different lines in a group mean within the robots.txt file in its help file on creating robots.txt<\/a>:<\/p>\n Each group consists of multiple rules or directives (instructions), one directive per line.<\/p>\n A group gives the following information:<\/p>\n I\u2019ll explain more about the different directives in a robots.txt file next.<\/p>\n Common syntax used within robots.txt includes the following:<\/p>\n User-agent refers to the bot in which you are giving the commands (for example, Googlebot or Bingbot). You can have multiple directives for different user agents. But when you use the * character (as shown in the previous section), that is a catch-all that means all user agents. You can see a list of user agents here<\/a>.<\/p>\n The Disallow rule specifies the folder, file or even an entire directory to exclude from Web robots access. Examples include the following:<\/p>\n Allow robots to spider the entire website:<\/p>\n User-agent: *<\/span> Disallow all robots from the entire website:<\/p>\n User-agent: *<\/span> Disallow all robots from \u201c\/myfolder\/\u201d and all subdirectories of \u201cmyfolder\u201d:<\/p>\n User-agent: *<\/span> Disallow all robots from accessing any file beginning with \u201cmyfile.html\u201d:<\/p>\n User-agent: *<\/span> Disallow Googlebot from accessing files and folders beginning with \u201cmy\u201d:<\/p>\n User-agent: googlebot<\/span> This command is only applicable to Googlebot and tells it that it can access a subdirectory folder or webpage even when its parent directory or webpage is disallowed.<\/p>\n Take the following example: Disallow all robots from the \/scripts\/folder except page.php:<\/p>\n Disallow: \/scripts\/<\/span> This tells bots how long to wait to crawl a webpage. Websites might use this to preserve server bandwidth. Googlebot does not recognize this command, and Google asks that you change the crawl rate via Search Console<\/a>. Avoid Crawl-delay if possible or use it with care as it can significantly impact the timely and effective crawling of a website.<\/p>\n Tell search engine bots where to find your XML sitemap in your robots.txt file. Example:<\/p>\n User-agent: *<\/span> To learn more about creating XML sitemaps, see this: What Is an XML Sitemap and How do I Make One?<\/a><\/strong><\/p>\n There are two characters that can help direct robots on how to handle specific URL types:<\/p>\n The * character.<\/strong> As mentioned earlier, it can apply directives to multiple robots with one set of rules. The other use is to match a sequence of characters in a URL to disallow those URLs.<\/p>\n For example, the following rule would disallow Googlebot from accessing any URL containing \u201cpage\u201d:<\/p>\n User-agent: googlebot<\/span> The $ character.<\/strong> The $ tells robots to match any sequence at the end of a URL. For example, you might want to block the crawling of all PDFs on the website:<\/p>\n User-agent: *<\/span> Note that you can combine $ and * wildcard characters, and they can be combined for allow and disallow directives.<\/p>\n For example, Disallow all asp files:<\/p>\n User-agent: *<\/span> If you do not want Google to index a page, there are other remedies for that other than the robots.txt file. As Google points out here<\/a>:<\/p>\n Which method should I use to block crawlers?<\/p>\n And here is more guidance from Google:<\/p>\n Blocking Google from crawling a page is likely to remove the page from Google’s index. Here are some tips to keep in mind as you create your robots.txt file:<\/p>\n Always test your robots.txt file. It is more common that you might think for website publishers to get this wrong, which can destroy your SEO strategy (like if you disallow the crawling of important pages or the entire website).<\/p>\n Use Google\u2019s robots.txt Tester tool. You can find information about that here<\/a>.<\/p>\n If you need a deeper dive than this article, download our Robots Exclusion Protocol Guide<\/a><\/strong>. It\u2019s a free PDF that you can save and print for reference to give you lots of specifics on how to build your robots.txt.<\/p>\n The robots.txt file is a seemingly simple file, but it allows website publishers to give complex directives on how they want bots to crawl a website. Getting this file right is critical, as it could obliterate your SEO program if done wrong.<\/p>\n Because there are so many nuances on how to use robots.txt, be sure to read Google\u2019s introduction to robots.txt<\/a>.<\/p>\n Do you have indexing problems or other issues that need technical SEO expertise? If you\u2019d like a free consultation and services quote, contact us today<\/a>.<\/strong><\/em><\/p>\n Ensuring your website’s optimal performance is paramount to success. A key aspect often overlooked is the strategic use of a robots.txt file. This unassuming text document wields the power to significantly impact your site’s search engine optimization (SEO) and overall performance.<\/p>\n At its core, a robots.txt file is a gatekeeper for search engine bots, guiding them on which parts of your website to crawl and index. By skillfully crafting this file, you can strategically control how search engines interact with your content. This optimization technique is vital for preventing unnecessary strain on your server, ensuring that valuable resources are allocated efficiently.<\/p>\n One essential application of robots.txt optimization is the ability to exclude specific pages or directories from being crawled. This is particularly useful for hiding unimportant or redundant pages, preventing search engines from wasting resources on irrelevant content. For instance, you can avoid video or audio files from being crawled, preserving your server’s bandwidth for more critical components.<\/p>\n Updating your website can be delicate, often requiring temporary withdrawal of specific pages. By utilizing robots.txt optimization, you can gracefully handle this situation without affecting SEO rankings. Temporarily blocking crawling on pages undergoing updates ensures that search engines won’t index incomplete or inconsistent content, maintaining your site’s credibility.<\/p>\n Moreover, robots.txt optimization empowers you to guide search engines toward your sitemap’s location. This simple step helps search engine bots navigate your site’s structure efficiently, ensuring no valuable content is overlooked. Strategically placing your sitemap in robots.txt enhances the discoverability of your most important pages.<\/p>\n While the benefits of robots.txt optimization are substantial, it’s crucial to proceed cautiously. Improper configuration can inadvertently block important pages, leading to declining search engine rankings. Therefore, seeking the guidance of SEO experts or referring to reputable resources, such as Google’s guidelines, is highly recommended before implementing changes.<\/p>\n A practical robots.txt file is a powerful tool in your SEO arsenal. By optimizing this seemingly unassuming element, you can exert control over how search engines interact with your website, ultimately enhancing performance, resource allocation, and overall user experience.<\/p>\n Step-by-Step Procedure for robots.txt Optimization:<\/strong><\/p>\n The one technical SEO element you don\u2019t want to get wrong is robots.txt. So here’s a handy guide that explains why every website needs it and how to create one.<\/p>\n","protected":false},"author":35,"featured_media":124205,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"categories":[4],"tags":[1589,1590,1232,1579,1588],"acf":[],"yoast_head":"
\nAh, robots.txt \u2014 one teeny tiny file with big implications. This is one technical SEO element you don\u2019t want to get wrong, folks.<\/p>\n\n
<\/a>What Is robots.txt?<\/h2>\n
<\/a>Why Is robots.txt Important?<\/h2>\n
\n
<\/a>But, Is robots.txt Necessary?<\/h2>\n
<\/a>What Problems Can Occur with robots.txt?<\/h2>\n
1. Blocking your whole site by accident<\/h3>\n
2. Excluding pages that are already indexed<\/h3>\n
<\/a>How Does robots.txt Work?<\/h2>\n
\nDisallow: \/directory-name\/<\/span><\/p>\n\n
Robots.txt Directives<\/h3>\n
User-agent<\/h4>\n
Disallow<\/h4>\n
\nDisallow:<\/span><\/p>\n
\nDisallow: \/<\/span><\/p>\n
\nDisallow: \/myfolder\/<\/span><\/p>\n
\nDisallow: \/myfile.html<\/span><\/p>\n
\nDisallow: \/my<\/span><\/p>\nAllow<\/h4>\n
\nAllow: \/scripts\/page.php<\/span><\/p>\nCrawl-delay<\/h4>\n
Sitemap<\/h4>\n
\nDisallow: \/directory-name\/<\/span>
\nSitemap: https:\/\/www.domain.com\/sitemap.xml<\/span><\/p>\nWildcard Characters<\/h3>\n
\nDisallow: \/*page<\/span><\/p>\n
\nDisallow: \/*.pdf$<\/span><\/p>\n
\nDisallow: \/*asp$<\/span><\/p>\n\n
Not Crawling vs. Not Indexing<\/h3>\n
\n
\nHowever, robots.txt Disallow does not guarantee that a page will not appear in results: Google may still decide, based on external information such as incoming links, that it is relevant. If you wish to explicitly block a page from being indexed, you should instead use the noindex robots meta tag or X-Robots-Tag HTTP header. In this case, you should not disallow the page in robots.txt, because the page must be crawled in order for the tag to be seen and obeyed.<\/p><\/blockquote>\n<\/a>Tips for Creating a robots.txt without Errors<\/h2>\n
\n
<\/a>The robots.txt Tester<\/h2>\n
<\/a>Robots Exclusion Protocol Guide<\/h2>\n
Closing Thoughts<\/h2>\n
<\/a>FAQ: How can I optimize my website’s performance with an effective robots.txt file?<\/strong><\/h3>\n
\n