One of the first files you should add to your website is "
/robots.txt".   This is a plaintext file for the Robots Exclusion Protocol (ROBOTS language, Internet Society Request for Comments [RFC] 9309).  What the "
/robots.txt" file does is instruct which webdirectories should be accessed or avoided by web bots.
An important thing to remember is that no bot is required to follow the Robots Exclusion Protocol.    The protocol only affects the behavior of compliant or well-behaved bots and anyone can program a bot to ignore the Robots Exclusion Protocol. As such, you should not use the Robots Exclusion Protocol to try to hide sensitive directories, especially since publicly listing the directories in "
/robots.txt" simply gives malicious bots an easy way to find the very directories you don't want them to visit.  On Apache HTTP (Hypertext Transfer Protocol) Server, you should use "
/.htaccess" (hypertext access) instead to hide directories from public access.
- Internet Society RFC 9309: Robots Exclusion Protocol
robotstxt.org: The Web Robots Pages
- Google Developers: Introduction to
As with all webtext files, you should use an advanced text editor such as Notepad-Plus-Plus (not Microsoft Windows Notepad).  Files should be saved with Unix line endings and UTF-8 (Unicode Transformation Format Eight-Bit) character encoding.
robots.txt" will only work from the root webdirectory ("
Comments are added to the Robots Exclusion Protocol with a hash ("
#") at the beginning of a new line.
# A comment.
For a public website, you want to allow access to all bots in order to get the site crawled and indexed by as many search engines as possible. The following "
/robots.txt" allows all bots access to all files and directories (minus anything excluded by "
User-agent: * Disallow: # All bots can crawl/index all files and directories.
Websites and webdirectories that are not publicly indexed on search engines are referred to as the "deep web" or "deepnet" (not to be confused with the "dark web" or "darknet").   For example, you may want to create a mirror of your website for testing purposes but don't want the development website publicly indexed since it will create duplicate or misleading results on search engines. The following "
/robots.txt" creates a "deepnet" website that instructs all bots compliant with the Robots Exclusion Protocol to not crawl or index any part of the site.
User-agent: * Disallow: / # No compliant bots will crawl/index any files or directories.
The following "
/robots.txt" excludes two webdirectories ("
/sandbox/" and "
/testbox/") from crawling/indexing but permits access to all other files and directories on the site.
User-agent: * Disallow: /sandbox/ Disallow: /testbox/ # Compliant bots will crawl/index all files and directories except for "/sandbox/" and "/testbox/" (exclusion is applied recursively to all subdirectories of "sandbox" and "testbox").
SITEMAP is an extension of the Robots Exclusion Protocol to allow listing a sitemap in the "
/robots.txt" file.     Having a precompiled list of links for the website available makes the bot's job to crawl and index the site a lot easier and more efficient. Since the first thing a good bot does when accessing a website is to check for a "
/robots.txt" file, it is best to have the link to the sitemap listed directly in the "
/robots.txt" file so the bot doesn't have to guess whether or not the website has a sitemap available (which could be either "
/sitemap.txt" or "
/sitemap.xml"). The following "
/robots.txt" provides an example of a public website with a sitemap. Note that unlike the other ROBOTS instructions, the sitemap should be provided with a full URL (uniform resource locator) and not with a relative link.
User-agent: * Disallow: Sitemap: https://www.example.net/sitemap.xml
Additional protocols such as SECURITY and HUMANS can also be added to the Robots Exclusion Protocol but these are not officially supported so should be commented out to avoid confusing bots while still allowing nonbot users to find the relevant files. The example below shows "
/robots.txt" for a public website that includes additional protocols for SITEMAP, SECURITY, and HUMANS.
User-agent: * Disallow: Sitemap: https://www.example.net/sitemap.txt # Security: https://www.example.net/.well-known/security.txt # Humans: https://www.example.net/humans.txt
Nicole Sharp's Website
Below is the Robots Exclusion Protocol of "
nicolesharp.net/robots.txt" showing hidden directories ("
/sandbox/" and "
/testbox/") for webdevelopment plus additional protocols and comments, including a comment line to provide attribution to the author of the file (Nicole Sharp).
User-agent: * Disallow: /sandbox/ Disallow: /testbox/ Sitemap: https://www.nicolesharp.net/sitemap.txt # Security: https://www.nicolesharp.net/security.txt # Humans: https://www.nicolesharp.net/humans.txt # Robots Exclusion Protocol for Nicole Sharp's Website. # 2023-09-04 Nicole Sharp # https://www.nicolesharp.net/
$wgNoFollowLinks = false; # https://www.mediawiki.org/wiki/$wgNoFollowLinks
commons:category:robots in art
bots, development, HUMANS, humans.txt, indexing, ROBOTS, robots.txt, SECURITY, security.txt, searchbots, SITEMAP, sitemap.txt, TXT, web, webcrawlers, webcrawling, webdevelopment, WWW