robots.txt

From HandWiki
Revision as of 18:15, 6 February 2024 by MainAI5 (talk | contribs) (link)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Short description: Standard used to advise web crawlers and scrapers not to index a web page or site

robots.txt is the filename used for implementing the Robots Exclusion Protocol, a standard used by websites to indicate to visiting web crawlers and other web robots which portions of the website they are allowed to visit.

This relies on voluntary compliance. Not all robots comply with the standard; indeed, email harvesters, spambots, malware and robots that scan for security vulnerabilities may very well start with the portions of the website they have been asked (by the Robots Exclusion Protocol) to stay out of.

The "robots.txt" file can be used in conjunction with sitemaps, another robot inclusion standard for websites.

History

The standard was proposed by Martijn Koster,[1][2] when working for Nexor[3] in February 1994[4] on the www-talk mailing list, the main communication channel for WWW-related activities at the time. Charles Stross claims to have provoked Koster to suggest robots.txt, after he wrote a badly-behaved web crawler that inadvertently caused a denial-of-service attack on Koster's server.[5]

It quickly became a de facto standard that present and future web crawlers were expected to follow; most complied, including those operated by search engines such as WebCrawler, Lycos, and AltaVista.[6]

On July 1, 2019, Google announced the proposal of the Robots Exclusion Protocol as an official standard under Internet Engineering Task Force.[7] A proposed standard[8] was published in September 2022 as RFC 9309.

Standard

When a site owner wishes to give instructions to web robots they place a text file called robots.txt in the root of the web site hierarchy (e.g. https://www.example.com/robots.txt). This text file contains the instructions in a specific format (see examples below). Robots that choose to follow the instructions try to fetch this file and read the instructions before fetching any other file from the website. If this file does not exist, web robots assume that the website owner does not wish to place any limitations on crawling the entire site.

A robots.txt file contains instructions for bots indicating which web pages they can and cannot access. Robots.txt files are particularly important for web crawlers from search engines such as Google.

A robots.txt file on a website will function as a request that specified robots ignore specified files or directories when crawling a site. This might be, for example, out of a preference for privacy from search engine results, or the belief that the content of the selected directories might be misleading or irrelevant to the categorization of the site as a whole, or out of a desire that an application only operates on certain data. Links to pages listed in robots.txt can still appear in search results if they are linked to from a page that is crawled.[9]

A robots.txt file covers one origin. For websites with multiple subdomains, each subdomain must have its own robots.txt file. If example.com had a robots.txt file but a.example.com did not, the rules that would apply for example.com would not apply to a.example.com. In addition, each protocol and port needs its own robots.txt file; http://example.com/robots.txt does not apply to pages under http://example.com:8080/ or https://example.com/.

Some major search engines following this standard include Ask,[10] AOL,[11] Baidu,[12] DuckDuckGo,[13] Google,[14] Yahoo!,[15] and Yandex.[16] Bing[17] is still[when?] not fully compatible with the standard as it cannot inherit settings from the wildcard character (*).[18]

The volunteering group Archive Team explicitly ignores robots.txt directives, using it instead for discovering more links, such as sitemaps.[19] The group views it as an obsolete standard that hinders web archival efforts. According to project leader Jason Scott, "unchecked, and left alone, the robots.txt file ensures no mirroring or reference for items that may have general use and meaning beyond the website's context."[20]

For some years, the Internet Archive did not crawl sites with robots.txt, but in April 2017, it announced that it would no longer honour directives in the robots.txt files.[21] "Over time we have observed that the robots.txt files that are geared toward search engine crawlers do not necessarily serve our archival purposes".[22] This was in response to entire domains being tagged with robots.txt when the content became obsolete.[22]

Security

Despite the use of the terms "allow" and "disallow", the protocol is purely advisory and relies on the compliance of the web robot; it cannot enforce any of what is stated in the file. [23] Malicious web robots are unlikely to honor robots.txt; some may even use the robots.txt as a guide to find disallowed links and go straight to them. While this is sometimes claimed to be a security risk,[24] this sort of security through obscurity is discouraged by standards bodies. The National Institute of Standards and Technology (NIST) in the United States specifically recommends against this practice: "System security should not depend on the secrecy of the implementation or its components."[25] In the context of robots.txt files, security through obscurity is not recommended as a security technique.[26]

Alternatives

Many robots also pass a special user-agent to the web server when fetching content.[27] A web administrator could also configure the server to automatically return failure (or pass alternative content) when it detects a connection using one of the robots.[28][29]

Some sites, such as Google, host a humans.txt file that displays information meant for humans to read.[30] Some sites such as GitHub redirect humans.txt to an About page.[31]

Previously, Google had a joke file hosted at /killer-robots.txt instructing the Terminator not to kill the company founders Larry Page and Sergey Brin.[32][33]

Examples

This example tells all robots that they can visit all files because the wildcard * stands for all robots and the Disallow directive has no value, meaning no pages are disallowed.

User-agent: *
Disallow: 
User-agent: *
Allow: /

The same result can be accomplished with an empty or missing robots.txt file.

This example tells all robots to stay out of a website:

User-agent: *
Disallow: /

This example tells all robots not to enter three directories:

User-agent: *
Disallow: /cgi-bin/
Disallow: /tmp/
Disallow: /junk/

This example tells all robots to stay away from one specific file:

User-agent: *
Disallow: /directory/file.html

All other files in the specified directory will be processed.

User-agent: BadBot # replace 'BadBot' with the actual user-agent of the bot
Disallow: /

This example tells two specific robots not to enter one specific directory:

User-agent: BadBot # replace 'BadBot' with the actual user-agent of the bot
User-agent: Googlebot
Disallow: /private/

Example demonstrating how comments can be used:

# Comments appear after the "#" symbol at the start of a line, or after a directive
User-agent: * # match all bots
Disallow: / # keep them out

It is also possible to list multiple robots with their own rules. The actual robot string is defined by the crawler. A few robot operators, such as Google, support several user-agent strings that allow the operator to deny access to a subset of their services by using specific user-agent strings.[14]

Example demonstrating multiple user-agents:

User-agent: googlebot        # all Google services
Disallow: /private/          # disallow this directory

User-agent: googlebot-news   # only the news service
Disallow: /                  # disallow everything

User-agent: *                # any robot
Disallow: /something/        # disallow this directory

Nonstandard extensions

Crawl-delay directive

The crawl-delay value is supported by some crawlers to throttle their visits to the host. Since this value is not part of the standard, its interpretation is dependent on the crawler reading it. It is used when the multiple burst of visits from bots is slowing down the host. Yandex interprets the value as the number of seconds to wait between subsequent visits.[16] Bing defines crawl-delay as the size of a time window (from 1 to 30 seconds) during which BingBot will access a web site only once.[34] Google provides an interface in its search console for webmasters, to control the Googlebot's subsequent visits.[35]

User-agent: bingbot
Allow: /
Crawl-delay: 10

Sitemap

Some crawlers support a Sitemap directive, allowing multiple Sitemaps in the same robots.txt in the form Sitemap: full-url:[36]

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

Universal "*" match

The Robot Exclusion Standard does not mention the "*" character in the Disallow: statement.[37]

Meta tags and headers

In addition to root-level robots.txt files, robots exclusion directives can be applied at a more granular level through the use of Robots meta tags and X-Robots-Tag HTTP headers. The robots meta tag cannot be used for non-HTML files such as images, text files, or PDF documents. On the other hand, the X-Robots-Tag can be added to non-HTML files by using .htaccess and httpd.conf files.[38]

A "noindex" meta tag
<meta name="robots" content="noindex" />
A "noindex" HTTP response header
X-Robots-Tag: noindex

The X-Robots-Tag is only effective after the page has been requested and the server responds, and the robots meta tag is only effective after the page has loaded, whereas robots.txt is effective before the page is requested. Thus if a page is excluded by a robots.txt file, any robots meta tags or X-Robots-Tag headers are effectively ignored because the robot will not see them in the first place.[38]


Maximum size of a robots.txt file

The Robots Exclusion Protocol requires crawlers to parse at least 500 kibibytes (KiB) of robots.txt files,[39] which Google maintains as a 500 kibibyte file size restriction for robots.txt files .[40]

See also


References

  1. "Historical". http://www.greenhills.co.uk/historical.html. 
  2. Fielding, Roy (1994). "Maintaining Distributed Hypertext Infostructures: Welcome to MOMspider's Web" (PostScript). First International Conference on the World Wide Web. http://www94.web.cern.ch/WWW94/PapersWWW94/fielding.ps. 
  3. "The Web Robots Pages". Robotstxt.org. 1994-06-30. http://www.robotstxt.org/orig.html#status. 
  4. Koster, Martijn (25 February 1994). "Important: Spiders, Robots and Web Wanderers" (Hypermail archived message). www-talk mailing list. http://inkdroid.org/tmp/www-talk/4113.html. 
  5. "How I got here in the end, part five: "things can only get better!"". Charlie's Diary. 19 June 2006. http://www.antipope.org/charlie/blog-static/2009/06/how_i_got_here_in_the_end_part_3.html. 
  6. Barry Schwartz (30 June 2014). "Robots.txt Celebrates 20 Years Of Blocking Search Engines". Search Engine Land. http://searchengineland.com/robots-txt-celebrates-20-years-blocking-search-engines-195479. 
  7. "Formalizing the Robots Exclusion Protocol Specification" (in en). https://webmasters.googleblog.com/2019/07/rep-id.html. 
  8. Koster, M.; Illyes, G.; Zeller, H.; Sassman, L. (2022-09-14). "Robots Exclusion Protocol". https://www.rfc-editor.org/rfc/rfc9309.html. 
  9. "Uncrawled URLs in search results". YouTube. Oct 5, 2009. https://www.youtube.com/watch?v=KBdEwpRQRD0#t=196s. 
  10. "About Ask.com: Webmasters". http://about.ask.com/docs/about/webmasters.shtml. 
  11. "About AOL Search". http://search.aol.com/aol/about. 
  12. "Baiduspider". http://www.baidu.com/search/spider_english.html. 
  13. "DuckDuckGo Bot". https://duckduckgo.com/duckduckbot. 
  14. 14.0 14.1 "Webmasters: Robots.txt Specifications". Google Developers. https://developers.google.com/webmasters/control-crawl-index/docs/robots_txt. 
  15. "Submitting your website to Yahoo! Search". http://help.yahoo.com/kb/index?page=content&y=PROD_SRCH&locale=en_US&id=SLN2217&impressions=true. 
  16. 16.0 16.1 "Using robots.txt". http://help.yandex.com/webmaster/?id=1113851. 
  17. "Robots Exclusion Protocol: joining together to provide better documentation". https://blogs.bing.com/webmaster/2008/06/03/robots-exclusion-protocol-joining-together-to-provide-better-documentation/. 
  18. "How to Create a Robots.txt File - Bing Webmaster Tools". https://www.bing.com/webmaster/help/how-to-create-a-robots-txt-file-cb7c31ec. 
  19. "ArchiveBot: Bad behavior". Archive Team. https://wiki.archiveteam.org/index.php/ArchiveBot#Bad_behavior. 
  20. Jason Scott. "Robots.txt is a suicide note". Archive Team. http://www.archiveteam.org/index.php?title=Robots.txt. 
  21. "Robots.txt meant for search engines don't work well for web archives | Internet Archive Blogs" (in en-US). 17 April 2017. https://blog.archive.org/2017/04/17/robots-txt-meant-for-search-engines-dont-work-well-for-web-archives/. 
  22. 22.0 22.1 Jones, Brad (24 April 2017). "The Internet Archive Will Ignore Robots.txt Files to Maintain Accuracy". Digital Trends. https://www.digitaltrends.com/computing/internet-archive-robots-txt/#ixzz4gQYOqpUi. 
  23. "Block URLs with robots.txt: Learn about robots.txt files". https://support.google.com/webmasters/answer/6062608. 
  24. "Robots.txt tells hackers the places you don't want them to look". The Register. https://www.theregister.co.uk/2015/05/19/robotstxt/. 
  25. Scarfone, K. A.; Jansen, W.; Tracy, M. (July 2008). Guide to General Server Security. National Institute of Standards and Technology. doi:10.6028/NIST.SP.800-123. http://csrc.nist.gov/publications/nistpubs/800-123/SP800-123.pdf. Retrieved August 12, 2015. 
  26. Sverre H. Huseby (2004). Innocent Code: A Security Wake-Up Call for Web Programmers. John Wiley & Sons. pp. 91–92. ISBN 9780470857472. https://books.google.com/books?id=RjVjgPQsKogC&pg=PA92. Retrieved 2015-08-12. 
  27. "List of User-Agents (Spiders, Robots, Browser)". User-agents.org. http://www.user-agents.org/. 
  28. "Access Control - Apache HTTP Server". Httpd.apache.org. https://httpd.apache.org/docs/2.2/howto/access.html. 
  29. "Deny Strings for Filtering Rules : The Official Microsoft IIS Site". Iis.net. 2013-11-06. http://www.iis.net/configreference/system.webserver/security/requestfiltering/filteringrules/filteringrule/denystrings. 
  30. "Google humans.txt". https://www.google.com/humans.txt. 
  31. "Github humans.txt". https://github.com/humans.txt. 
  32. Newman, Lily Hay (2014-07-03). "Is This a Google Easter Egg or Proof That Skynet Is Actually Plotting World Domination?" (in en). https://slate.com/technology/2014/07/a-killer-robots-txt-google-easter-egg.html. 
  33. "/killer-robots.txt". 2018-01-10. https://www.google.com/killer-robots.txt. 
  34. "To crawl or not to crawl, that is BingBot's question". 3 May 2012. https://blogs.bing.com/webmaster/2012/05/03/to-crawl-or-not-to-crawl-that-is-bingbots-question/. 
  35. "Change Googlebot crawl rate - Search Console Help" (in en). https://support.google.com/webmasters/answer/48620?hl=en. 
  36. "Yahoo! Search Blog - Webmasters can now auto-discover with Sitemaps". http://ysearchblog.com/2007/04/11/webmasters-can-now-auto-discover-with-sitemaps/. 
  37. "Robots.txt Specifications". https://developers.google.com/search/reference/robots_txt?hl=en. 
  38. 38.0 38.1 "Robots meta tag and X-Robots-Tag HTTP header specifications - Webmasters — Google Developers". https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag. 
  39. Koster, Martijn. "RFC 9309: Robots Exclusion Protocol" (in en). https://www.rfc-editor.org/rfc/rfc9309#name-limits. 
  40. "How Google Interprets the robots.txt Specification | Documentation" (in en). https://developers.google.com/search/docs/crawling-indexing/robots/robots_txt. 

External links