Skip to content
SearchLearningToolsSEO & GEO
Back to guides

Creating a Robots.txt File: Complete Technical Guide & Best Practices

12 min read•Beginner to Intermediate•Published Oct 4, 2026•Last updated September 10, 2026•By SearchLearningTools Team• Production-Tested
2-Minute Action Step: Test This In Real-Time

Put this guide into practice with our free companion browser tools.

100% free, client-side private, and zero sign-up required. Run keyword clustering, schema generation, or SERP previews in seconds.

Launch Free Tools →
Robots.txt quick reference showing user-agent, allow, disallow, and sitemap directives, with a reminder that robots.txt is not a security boundary.
A robots.txt example with crawler directives and their limitations.Generate a WordPress robots.txt file →

Creating a Robots.txt File for Modern Search Engines & AI

A robots.txt file is a plain text file placed in the root directory of your website (e.g., https://yourdomain.com/robots.txt) that instructs automated web robots and search engine crawlers which pages they can or cannot request from your site.

Adhering to the Robots Exclusion Standard (RFC 9309), a properly configured robots.txt file preserves your server crawl budget, prevents duplicate content indexing, and ensures generative AI models can parse your authoritative content.


Anatomy of a Robots.txt File

A robots.txt file consists of one or more directive blocks composed of:

1. User-agent Directive

Specifies which crawler the following rules apply to:

# Applies to all compliant web crawlers
User-agent: *

# Targets Googlebot specifically
User-agent: Googlebot

# Targets OpenAI search and citation crawler
User-agent: OAI-SearchBot

2. Disallow Directive

Instructs the crawler not to fetch specific URL paths:

Disallow: /admin/
Disallow: /checkout/
Disallow: /api/

3. Allow Directive

Explicitly permits access to a specific sub-path within an otherwise disallowed directory:

Disallow: /wp-includes/
Allow: /wp-includes/js/
Allow: /wp-includes/css/

4. Sitemap Directive

Points crawlers directly to your absolute XML sitemap location:

Sitemap: https://yourdomain.com/sitemap.xml

Custom Robot Txt Generator for WordPress & Next.js

When creating a robots.txt file, standard templates differ based on your CMS architecture:

WordPress Recommended Configuration

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /cart/
Disallow: /checkout/
Disallow: /my-account/
Disallow: /?s=

# Allow AI Citation Crawlers
User-agent: GPTBot
Allow: /

User-agent: PerplexityBot
Allow: /

Sitemap: https://yourdomain.com/sitemap_index.xml

Use our dedicated Robots.txt Generator for WordPress to generate this configuration with 1-click download.


4 Critical Mistakes to Avoid When Creating Robots.txt

  1. Never Disallow the Root Directory (`Disallow: /`): This tells search engines to de-index your entire domain.
  2. Never Block CSS or JavaScript Bundles: Googlebot renders web pages as a headless browser. Blocking static stylesheets or Next.js static bundles (/_next/static/) prevents Google from testing mobile-friendliness.
  3. Do Not Rely on Robots.txt for Sensitive Security: Robots.txt is publicly visible. Do not list private URL paths that you do not want malicious scrapers to discover. Use HTTP authentication and noindex headers instead.
  4. Test Before Publishing: Test your live directives using our Robots.txt AI Crawler Tester to ensure desired search visibility.
SL

Search Learning Tools Editorial Team

• Lead Search Practitioner

Specializing in Technical SEO architecture, Generative Engine Optimization (GEO), and Schema.org structured data. Audits search retrieval models and entity attribution.

Author verification: Published on Search Learning Tools • Contact via Editorial Team

Found this helpful? Share it:

Share on Twitter

Turn the lesson into a workflow

The free guide explains the reasoning. Use the prompt generator to create a starting point for your next research, briefing, or optimization task.

Try the free AI SEO prompt generator

Questions About SEO Tools?

Yes, the core SEO tools are free. The optional AI SEO Prompt System adds structured workflows for a one-time $7.99.

It generates topic-based keyword ideas and intent labels for your review. It does not provide search-volume estimates, so validate demand with your preferred keyword data source.

You can use the generated drafts as a starting point for client work. Review the output, confirm facts, and follow your client's data and publishing policies before using it.

The AI SEO Prompt System is a practical collection of prompts for ChatGPT, Claude, and Gemini covering keyword research, content creation, technical SEO, and optimization. It is a one-time $7.99 purchase.

Tool updates are released as improvements are ready. Check the tool pages and release information for the current capabilities.

Review the site privacy information before entering sensitive material. Avoid submitting confidential client data to any browser-based tool unless your organization has approved it.

Start with the AI Keyword Generator to explore a seed topic, then use Content Optimizer to review structure and keyword placement, followed by Meta Description Generator to draft a search snippet.

They can help you plan and review content, but they do not guarantee rankings, traffic, or a particular timeframe. Measure results in your own Search Console and analytics data.

Corner 6 of 6 • Full-Stack Technical Telemetry 3-6-9 Law of Trust Verified

Canonical Trust & Verification Matrix: Questions About SEO Tools?

Canonical Topic Definition (HTTP Status, Canonical Integrity & SERP Pixel Width Verification)

Full-Stack Technical Telemetry audits live HTTP 200 responses, 301/308 redirect hops, self-referencing canonical tags, single H1 hierarchy, and HTML5 Canvas Arial 20px SERP title widths (≤580px desktop) to eliminate indexing friction.

Deterministic Formula:Indexability_Health = HTTP_200 ∧ (Canonical == Self_URL) ∧ (H1_Count == 1) ∧ (Title_Canvas_Px <= 580)
3-6-9 Law of Trust Verification Matrix for Questions About SEO Tools? across Google Search (Corner 3), Human Users (Corner 6), and AI Answer Engines (Corner 9).
3-6-9 Trust CornerTrust Issue ResolvedSearchLearningTools Canonical StandardDeterministic Verification Proof
Corner 3 • Google SearchEliminates scaled fluff, hidden DOM FAQs, redirect chains & fabricated review stars40–60w Answer-First blocks, 100% visible SSR parity & self-referencing canonical URLHTTP 200 ∧ Canonical == Self ∧ 0 Fake Ratings
Corner 6 • Human UsersEliminates bait-and-switch paywalls, mandatory signups & opaque black-box scoresZero login walls, client-side privacy & connected workflow: Website SEO Auditor → URL Redirect Checker0 Bytes Stored • Open Formula • CSV/Copy Ready
Corner 9 • AI Engines (RAG)Eliminates high-perplexity narrative walls, blocked search bots & unverified statsSemantic HTML Trust Matrix (<th scope="col/row">), RFC 9309 bot allow & /llms-full.txtAllow(OAI, Perplexity, Claude) • CC BY 4.0

Community Q&A

Questions and answers for this guide

Ask a question or leave a quick review

Maya

Sep 12, 2026

The keyword clustering prompts are clear, and the workflow helps me explain the why behind each content brief.

Leo

Sep 14, 2026

I used the AI visibility checklist before publishing a guide and it caught a few gaps around direct-answer structure and heading clarity.

Free SEO tools and guides

Try a relevant tool while you work through this guide.