Robots.txt is a crawler access convention. It can reduce crawling of unimportant paths, but a blocked URL may still appear in search results if other pages link to it. Use authentication for private content and noindex when a page should not appear in search after it can be crawled.
Before You Begin
- Access to the website document root or deployment configuration.
- A list of paths that should be crawlable or excluded from crawling.
- A test plan for important pages and assets.
Recommended Approach
1. Create the file at the correct location
Publish the file at the root of the host, for example `https://example.com/robots.txt`. Rules are scoped to the host, protocol, and port where the file is served.
2. Define crawler groups
Use `User-agent` to identify a crawler group and `Disallow` or `Allow` rules for paths. Keep rules simple and avoid blocking CSS, JavaScript, or image resources needed to render important pages.
3. Add the sitemap location
You can include an absolute Sitemap directive to help crawlers locate the XML sitemap. This directive is independent of the user-agent group.
4. Test the rules
Fetch robots.txt from the public site and review the actual response. Use Search Console tools where available and inspect important URLs to ensure they are not unintentionally blocked.
5. Use the right control for private or excluded pages
Protect private content with authentication. Use a noindex directive when a page should be excluded from search, making sure crawlers are allowed to fetch the page and see that directive.
Operational Considerations
Search visibility and website quality improve through consistent maintenance rather than one-time submissions. Keep important pages linked from relevant navigation and related articles, use descriptive titles and headings, and ensure that each page has a clear purpose. Review canonical URLs, redirects, internal links, and indexability when content is moved or reorganized. Keep a change history so a sudden drop in visibility or performance can be compared with recent releases.
How to Verify the Result
Use Search Console and performance tools as diagnostic sources, not as a promise of a particular ranking or indexing date. Compare trends over time, inspect representative URLs, and distinguish crawling, indexing, ranking, and user engagement. After making a change, verify the live response and rendered page, then monitor the relevant report rather than repeatedly submitting the same URL.
Example Configuration
Illustrative example — adapt values to your environment
User-agent: *
Disallow: /admin/
Disallow: /private/
Sitemap: https://example.com/sitemap.xml
Common Mistakes to Avoid
- Do not use robots.txt to protect confidential content; disallowed URLs can still be discovered.
- Blocking a URL does not reliably remove an already indexed result.
- Avoid broad Disallow rules that block the entire site or essential assets.
Make one change at a time, test it from the perspective of the actual user or application, and record the reason for the change. Keep a rollback path for network, identity, and production configuration changes.
Final Checklist
- The configuration matches the intended environment and service version.
- Access is limited to the required identities, resources, ports, and operations.
- The expected workflow has been tested, including a negative test for unauthorized access.
- Secrets and temporary credentials are protected and excluded from logs and source control.
- The configuration owner, purpose, and review or expiration date are documented.