Skip to content
Technical SEOrobots.txt

Robots Exclusion Protocol

Definition

A robots.txt file is a plain text document positioned at the root directory of a domain that instructs search engine web crawlers which URLs and directories they are permitted or forbidden to request.

Why It Matters

robots.txt prevents web scrapers and crawlers from overwhelming internal server resources with unnecessary requests to administrative endpoints, internal search queries, or staging environments. However, blocking a page in robots.txt does NOT prevent it from being indexed if external backlinks point to it; only noindex meta tags prevent indexing.

Robots.txt Standard Syntax Directives (RFC 9309)

Criterion / StateRequirement / TargetStatus
File LocationRoot domain only: https://domain.com/robots.txtOptimal
HTTP StatusMust return HTTP 200 OK with text/plain content typeOptimal
User-agentSpecifies crawler token (* for all, Googlebot, etc.)Standard
Sitemap LineInclude absolute XML sitemap URL directiveOptimal

Practical Implementation Example

Next.js MetadataRoute generates a valid, dynamic robots.txt file blocking private application routes while advertising the sitemap location to all search engines.

src/app/robots.ts
import type { MetadataRoute } from 'next';

export default function robots(): MetadataRoute.Robots {
  return {
    rules: [
      {
        userAgent: '*',
        allow: '/',
        disallow: ['/api/', '/dashboard/', '/admin/'],
      },
    ],
    sitemap: 'https://example.com/sitemap.xml',
  };
}
Automated Verification

How to Audit robots.txt in ScanWise

ScanWise audits your robots.txt syntax against the RFC 9309 standard, alerting you to unintentional disallow rules that block Googlebot from indexing key revenue routes.

Audit your robots.txt syntax and crawler directives in ScanWise

Common robots.txt Mistakes & How to Fix Them

Common robots.txt Mistakes & How to Fix Them
MistakeWhy It HurtsThe Fix
Using Disallow: / in production or forgetting to remove staging block rules after launching.A single Disallow: / line completely instructs all compliant search engines to halt crawling the entire domain.Environment-gate robots rules so Disallow: / is strictly confined to preview and staging hostnames.
Attempting to use Noindex: directives inside robots.txt.Google officially removed support for noindex in robots.txt in September 2019; it is completely ignored.Serve <meta name='robots' content='noindex'> HTML tags or X-Robots-Tag: noindex HTTP response headers.