PureTools

robots.txt: Control What Search Engines Crawl

PureTools Team· 5 min read
robots.txt: Control What Search Engines Crawl

robots.txt: The Bouncer at Your Website's Door

robots.txt is a plain text file at your site's root that tells search engine crawlers which pages they can and can't access. It's not a security mechanism — it's a polite request that well-behaved bots honor.

Basic Syntax

# Allow everything (default if no robots.txt exists)
User-agent: *
Allow: /

# Block everything (hide site from search engines)
User-agent: *
Disallow: /

# Block specific paths
User-agent: *
Disallow: /admin/
Disallow: /api/
Disallow: /private/
Disallow: /tmp/

# Reference your sitemap
Sitemap: https://example.com/sitemap.xml

Common Rules

# Block all bots from admin area
User-agent: *
Disallow: /admin/
Disallow: /dashboard/
Disallow: /api/
Disallow: /_next/       # Next.js internals
Disallow: /search?      # search result pages (duplicate content)

# Allow specific bot access to everything
User-agent: Googlebot
Allow: /

# Block specific bad bots
User-agent: AhrefsBot
Disallow: /

User-agent: SemrushBot
Disallow: /

# Sitemap location
Sitemap: https://example.com/sitemap.xml

Pattern Matching

# Block all PDF files
Disallow: /*.pdf$

# Block URLs with query parameters
Disallow: /*?*

# Block specific file types
Disallow: /*.json$
Disallow: /*.xml$

Common Mistakes

MistakeProblem
Using robots.txt as securityIt's public and advisory — anyone can ignore it
Disallow: / in productionBlocks ALL crawling — site disappears from Google
Blocking CSS/JS filesGoogle can't render your page, hurts rankings
No Sitemap referenceMissed opportunity to tell crawlers about all your pages
Blocking /images/Images won't appear in Google Image Search

Testing

Google Search Console has a robots.txt tester. Or check manually:

curl https://example.com/robots.txt

Generate yours: robots.txt Generator — select your rules, get a ready-to-use robots.txt file.