Eskillsfy

Home / Blog / Web and CSS

Web and CSS · 23 Nov 2026

Robots.txt Generator: how it works and how to build one

Create a robots.txt with rules, AI-bot blocking and sitemap. This guide explains what happens behind the button and shows the code, so you can build your own.

What it does

Choose what search engines may crawl, block folders like /admin, block AI crawlers such as GPTBot if you want, and add your sitemap. Download the file and upload it to your site’s root.

When to use it

  • New websites
  • Keeping crawlers out of admin and cart pages
  • Opting out of AI training

How to use it

  1. Choose the default and add rules.
  2. Decide on AI crawlers and add your sitemap URL.
  3. Download robots.txt and upload it to your site root.

Try it free in your browser, nothing is uploaded: https://eskillsfy.com/tools/robots-txt-generator

How it works

robots.txt is a plain text file at your site root with groups of rules. Each group starts with User-agent (which crawler) followed by Disallow and Allow paths. Crawlers use the most specific matching group.

AI crawlers have their own user-agent names (GPTBot, ClaudeBot, Google-Extended…), so blocking them is a separate group with Disallow: /.

Build it yourself

Here is the core of the tool. It has no dependencies unless noted, so you can paste it into any TypeScript or JavaScript project.

robots.ts (ts)

export function robotsTxt({ disallow = ["/admin/"], blockAi = false, sitemap = "" }) {
  const lines = ["User-agent: *", ...disallow.map((p) => `Disallow: ${p}`)];
  if (blockAi) lines.push("", ...["GPTBot", "ClaudeBot", "Google-Extended", "CCBot"].map((b) => `User-agent: ${b}`), "Disallow: /");
  if (sitemap) lines.push("", `Sitemap: ${sitemap}`);
  return lines.join("\n") + "\n";
}

Make it production-ready

  • Test paths against the rules before publishing.
  • In Next.js, generate it from app/robots.ts.

Questions

Does robots.txt hide pages?

No. It asks crawlers not to visit. Use a noindex tag or a login to keep a page out of search.

Try the Robots.txt Generator

Free, runs in your browser, nothing is uploaded.

Open it
Keep reading

More in Web and CSS

All posts