跳到正文
DEV Community· Avani Mehta·· 58 分鐘前AI 評分49

如何在本機建立 /llms.txt 和 AI robots.txt 設定檔

How to Build /llms.txt and AI robots.txt Configs Locally

AI 導讀

Minimax Tools 的 /llms.txt & AI Crawler Config Generator 可在瀏覽器本機生成 /llms.txt、/llms-full.txt 和 robots.txt AI 規則。工具在 JavaScript 中執行格式整理和規則組合,網站網址、產品摘要及爬蟲設定不會離開用戶的裝置。

正文

Shipping a documentation site or SaaS landing page today means two different audiences read your markup: humans in a browser and retrieval agents fetching context for Perplexity, ChatGPT Search, Claude, and Cursor. When an AI coding assistant or answer engine hits a modern web app, it rarely parses your navigation drawer, client-side tabs, or marketing hero cleanly. Instead, it burns context tokens on cookie banners, footer links, and hydration scripts, or misses your API reference entirely.

That's the exact bottleneck the /llms.txt proposal was created to solve. Rather than forcing an agent to guess which pages matter, you drop a single Markdown index at /llms.txt and pair it with explicit crawler directives in robots.txt. Writing both by hand for every project is tedious, though, and pasting your site structure or internal doc URLs into a cloud-hosted SaaS generator feels unnecessary when the output is just structured text.

Why In-Browser Generation Beats Hand-Editing and Cloud Forms

Hand-rolling /llms.txt in a text editor works fine for a five-page personal site, yet it breaks down quickly once you maintain multiple products, API versions, or client-facing microsites. One typo in a Markdown blockquote or a forgotten User-agent block in robots.txt can either break spec compliance or accidentally block the exact search crawler you wanted to allow.

Running a generator directly inside the browser solves both problems without introducing a backend dependency. Client-side web apps execute the formatting, template expansion, and rule assembly locally in JavaScript, so your URLs, product summaries, and bot-blocking preferences never leave your machine. There's no account wall, no rate limit, and no third-party server logging your unpublished doc routes before launch.

You also get instant side-by-side validation across all three files that AI crawlers look for:

  • /llms.txt: The lightweight Markdown table of contents defined by the llms.txt specification.
  • /llms-full.txt: The expanded single-file reference used when an agent wants deeper context in one fetch.
  • robots.txt AI rules: Explicit Allow and Disallow blocks for major LLM and AI search user-agents, following the standard Robots Exclusion Protocol (RFC 9309).

Step-by-Step Walkthrough: Generating Your AI Discovery Files

To test this workflow on a real project, let's build the discovery files for a typical SaaS documentation portal (https://docs.example-app.dev). We'll use the Minimax Tools /llms.txt & AI Crawler Config Generator, which runs 100% client-side and outputs all three formats in one pass.

1. Pick a Baseline Industry Template

When you open the tool, you'll see four Quick Industry Templates at the top: SaaS / Web App, Documentation & API, Ecommerce & Products, and Personal Blog / Portfolio. Clicking Documentation & API pre-populates sensible section headings like Core Docs, API Reference, and Guides so you don't start from a blank canvas.

If you're starting from scratch on an unusual site layout, hit Clear All to wipe the sample data and build your own section tree.

2. Fill in Site & Brand Basics

Next, complete the Site & Brand Basics block. This populates the H1 heading and the Markdown blockquote (>) that sits at the top of /llms.txt, which agents read first to understand what your site does:

  • Project / Website Name: ExampleApp Docs
  • Base Website URL: https://docs.example-app.dev
  • Elevator Pitch / Summary: Developer documentation, REST API endpoints, and webhook guides for ExampleApp's real-time event pipeline.

Keep the elevator pitch to one or two concrete sentences. Agents use this summary to decide whether your domain is relevant before following any nested links.

3. Organize Curated Content Sections

Under Curated Content Sections, group your canonical URLs by topic rather than dumping your entire XML sitemap. A clean setup for a developer product looks like this:

  • Core Docs: Quickstart (/docs/quickstart), Authentication (/docs/auth), Rate Limits (/docs/rate-limits)
  • API Reference: Events API (/api/events), Webhooks (/api/webhooks), SDKs (/api/sdks)
  • Optional: Changelog (/changelog), Status Page (/status)

Using the Optional section is a smart habit from the /llms.txt spec. It tells context-constrained agents which pages they can safely skip when token budgets are tight.

4. Configure AI Crawler Permissions (robots.txt)

In the AI Crawler Permissions panel, toggle which bots can read your content. The generator includes dedicated switches for the major user-agents:

  • GPTBot & ChatGPT-User: OpenAI's indexer and live ChatGPT Browse agent.
  • ClaudeBot: Anthropic's web search and documentation crawler.
  • PerplexityBot: Perplexity AI's live search engine crawler.
  • Google-Extended: Google's control token for Gemini and Vertex AI training/citation, documented in Google's crawler overview.
  • cohere-ai: Cohere's enterprise RAG and search agent.
  • Bytespider: ByteDance's crawler, which many teams choose to disallow due to aggressive crawl rates.

For a public documentation site, you'll usually allow PerplexityBot, ClaudeBot, GPTBot, and Google-Extended so developers get accurate answers when they ask an AI assistant about your API, while disallowing Bytespider to save origin bandwidth.

5. Export and Deploy

Switch between the /llms.txt Standard, /llms-full.txt, and robots.txt AI Config output tabs to inspect the generated files. Copy each output and place it at the root of your public static directory (for example, public/llms.txt in Next.js, Astro, or Vite), then append the generated bot rules to your existing public/robots.txt.

If you want to generate standard-compliant /llms.txt and AI crawler rules locally before deploying, you can also test the generated Markdown against your staging URLs first.

3 Real-World Use Cases

1. Developer Docs and SDK Portals

API documentation suffers the most from noisy HTML wrappers. Sidebars, version switchers, and interactive "Try It" widgets inflate page size without helping an LLM write a working curl request. Pointing /llms.txt straight to clean Markdown or canonical reference pages helps tools like Cursor and Claude fetch accurate parameter names on the first try.

2. Privacy-First Internal or Pre-Launch Sites

Teams preparing a product launch often draft their documentation map before the domain is public. Because client-side generators don't transmit form inputs to a remote server, you can map out unreleased endpoints, pricing tiers, and feature summaries without leaking roadmap details to third-party analytics.

3. Content Sites Balancing Search Visibility and Bandwidth

Publishers and independent blogs often want to appear in live answer engines (like Perplexity or ChatGPT Search) while blocking bulk scrapers that hammer origin servers without sending referral traffic. Generating a clean robots.txt AI block lets you apply granular Allow and Disallow rules per user-agent in under two minutes instead of hunting down exact bot strings across multiple blog posts.

Common Mistakes, Edge Cases, and Pro Tips

Even a valid /llms.txt file can underperform if you treat it like a raw sitemap.xml dump. Watch out for these common pitfalls:

  • Linking to 500+ URLs in /llms.txt: Keep /llms.txt focused on your highest-signal pages (usually 10 to 40 links). Huge lists defeat the purpose of a curated index.
  • Forgetting Content-Type: text/plain; charset=utf-8: Make sure your CDN or web server serves .txt files as plain text with UTF-8 encoding, not application/octet-stream that forces a file download.
  • Overwriting your existing robots.txt: Never replace your main robots.txt blindly. Append the AI crawler rules below your existing User-agent: * and Sitemap: directives so you don't accidentally drop standard Googlebot or Bingbot rules.
  • Ignoring robots.txt compliance limits: Remember that robots.txt is a voluntary standard, as noted in MDN's robots.txt guide. Well-behaved crawlers respect it, while rogue scrapers still require WAF or rate-limiting rules at your CDN edge.

Honest Trade-Offs: Browser Tool vs. Cloud SaaS vs. Build-Time CLI

Approach Privacy & Data Handling Setup Speed Best Fit
In-Browser Generator 100% local, zero server uploads Under 2 minutes, no install Quick setup, indie apps, pre-launch docs
Cloud SaaS Crawlers URLs and summaries processed on vendor servers 5-10 minutes (signup + crawl) Large marketing sites needing automated scraping
Build-Time CLI / Scripts Local in CI/CD pipeline 30-60 minutes to script and test Monorepos with hundreds of auto-generated MDX docs

When is a build-time CLI still the better choice? If your documentation has 800+ MDX files that change daily across multiple contributors, maintaining a static /llms.txt by hand in a browser UI will drift out of sync. In that scenario, use a browser generator to establish your baseline structure and robots.txt AI policy, then automate /llms-full.txt concatenation inside your framework's build step.

Practical FAQ

Does /llms.txt replace sitemap.xml?

No. sitemap.xml is built for traditional search engine crawlers (Googlebot, Bingbot) to discover every indexable URL on your domain. /llms.txt is a curated, human- and agent-readable Markdown index meant to fit cleanly inside an LLM context window.

Will blocking GPTBot in robots.txt remove my site from Google Search?

No. GPTBot is OpenAI's crawler, while Googlebot handles Google Search indexing. Even Google-Extended only controls Gemini and Vertex AI training/grounding—it does not de-index your pages from standard Google Search results.

Can I link directly to .md files inside /llms.txt?

Yes, and it's actually recommended if your static site generator outputs raw Markdown alongside HTML. Agents consume plain Markdown with far fewer tokens than rendered HTML pages.

Do I need both /llms.txt and /llms-full.txt?

Start with /llms.txt and robots.txt first. Add /llms-full.txt if you maintain developer documentation or an SDK where an AI coding assistant benefits from reading your full reference in a single request.

Wrap-Up

Getting your site ready for AI search and coding assistants doesn't require a new SaaS subscription or an afternoon of regex debugging. By pairing a focused /llms.txt index with explicit robots.txt crawler permissions, you control both how agents summarize your product and which bots are allowed to fetch your pages. Test your own site structure locally, verify the generated robots.txt directives against your existing rules, and ship clean discovery files in one commit.

來源:DEV Community · dev.to