Robots.txt SEO Guide

Robots.txt gives cooperating crawlers instructions about URLs they may fetch. It is normally served at the root of the relevant host. Use it to control crawling and publish your sitemap location when appropriate.

Read the rules as a crawler would

Check the user-agent group, then review its Allow and Disallow paths. A wildcard group applies broadly unless a more specific supported group takes precedence. An accidental `Disallow: /` can block a site’s main content from crawling.

A basic WordPress example allows public pages, restricts `/wp-admin/` and permits `/wp-admin/admin-ajax.php` when the site needs that endpoint.

Keep indexing and crawling distinct

A robots restriction limits fetching. It does not necessarily remove a discovered URL from search. For a public page that should not be indexed, use an appropriate noindex directive and allow the crawler to read it.

Keep confidential data behind access controls. A robots.txt file is publicly readable and does not enforce authorization.

Publish the correct sitemap URL

Use an absolute URL after `Sitemap:` and check that it resolves. For Rank Math, the primary index often appears at `/sitemap_index.xml`. Verify important public assets and page paths remain available.

Review environment-specific settings after a staging-to-production deployment so a staging rule does not carry over to the live site.

Test before closing the issue

Fetch robots.txt for the correct host and check representative URLs through Search Console. Record which rule changed and the actual result when Google next crawls.

Robots.txt, noindex and canonical: what each signal actually does

These controls solve different problems. A robots.txt disallow rule limits crawling of matching URLs. A noindex instruction asks search engines not to show an accessible page in results. A canonical indicates which of several similar URLs the website prefers. Confusing them can prevent Google from seeing the very signal you want it to follow.

For example, if an author archive should not appear in search, a crawlable archive with an appropriate noindex can be reasonable. Blocking the same archive with robots.txt may stop crawlers from seeing that noindex instruction. Likewise, a redirected old article should send users and crawlers to its intended replacement, not to the homepage without relevance.

A practical audit of a robots.txt file

  1. Confirm the file is publicly accessible at the site’s root and contains valid directives.
  2. Review rules for your actual content paths; do not accidentally block the services, blog articles or assets needed to render the site.
  3. Keep administrative endpoints restricted where appropriate, while ensuring essential public pages remain crawlable.
  4. Confirm that the sitemap reference points to the live, intended sitemap.
  5. Test a representative important URL using Search Console’s live URL inspection and review server behaviour separately if necessary.

Robots controls do not create search visibility by themselves. For a complete review, combine them with XML sitemap checks, canonical checks and quality internal links.

Related reading: XML Sitemap SEO Guide and Google’s robots.txt documentation.

A
ARTICLE BY

Ali Raza

SEO, link building and digital growth insights from Rank Raza.

READY TO GROW?

Need Help Growing Your Search Visibility?

Get a tailored SEO and link building strategy designed around your website, niche and growth goals.