What Is Robots.txt? A Beginner-Friendly Guide

Every well-run website has a tiny file at its root address: yoursite.com/robots.txt. Most visitors never see it, but search engine crawlers read it before anything else. So what is robots.txt, what can it do, and how do you avoid the classic mistake of accidentally hiding your whole site from Google? This guide explains it in plain language.

Screenshot of the Robots.txt Generator on Assen Tools
The Robots.txt Generator in use. Open the Robots.txt Generator – free, no sign-up.

The simple definition

Robots.txt is a plain text file that gives instructions to search engine crawlers (also called bots or spiders), such as Googlebot and Bingbot. It tells them which parts of your site they may crawl and which to skip, and where to find your sitemap.

It is a set of polite instructions, not a security system. Reputable crawlers obey it; malicious bots may ignore it.

How the file is structured

Robots.txt uses a few simple directives:

  • User-agent: which crawler the rules apply to. * means all crawlers.
  • Disallow: a path the crawler should not visit.
  • Allow: an exception inside a disallowed path.
  • Sitemap: the full address of your XML sitemap.

A typical safe file:

User-agent: *
Disallow: /admin/
Disallow: /cart/
Disallow: /search

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

This lets crawlers see everything except the admin area, cart and internal search results, and points them to the sitemap.

Example for WordPress

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php

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

What robots.txt does not do

This is where many people go wrong:

  • It does not remove pages from Google. A blocked page can still appear in results if other sites link to it – Google just cannot read its content. To keep a page out of search results, allow crawling and add a noindex meta tag instead.
  • It does not protect private data. Anyone can read your robots.txt, and listing secret folders actually advertises them. Use passwords and proper access control.
  • It is not a speed or security tool for stopping aggressive bots – use your host's firewall or a service like Cloudflare.

The most dangerous mistake

This two-line file blocks your entire website:

User-agent: *
Disallow: /

It is often left behind when a site moves from a development server to the live domain. If your traffic suddenly drops, check robots.txt first.

Other common mistakes

  • Blocking CSS and JavaScript files, which stops Google rendering your pages properly.
  • Forgetting that paths are case-sensitive: /Admin/ and /admin/ are different.
  • Placing the file anywhere other than the root of the domain.
  • Using robots.txt to hide duplicate pages instead of canonical tags – see what is a canonical URL.

Create yours without errors

The free Robots.txt Generator builds a correctly formatted file from simple options and adds your sitemap line. Upload it to the root folder of your website and visit yoursite.com/robots.txt to confirm it loads.

Need a sitemap to point to? Use the Sitemap Generator and read what is a sitemap. To confirm the file returns a 200 status, test it with the HTTP Status Code Checker.

Frequently asked questions

Does every site need robots.txt? It is optional – without one, crawlers assume they can visit everything. But a simple file with your sitemap line is good practice.

How quickly do changes take effect? Google usually re-reads robots.txt within a day.

Can I block AI crawlers? Many AI companies publish crawler names that respect robots.txt, and you can disallow them by user-agent.

Where do I test it? Google Search Console has a robots.txt report showing the version Google fetched and any errors.

Summary

So, what is robots.txt? A plain text file at the root of your site that tells search engine crawlers where they may go and where your sitemap lives. Use it to keep bots out of admin and cart pages, never to hide content from results, and never leave "Disallow: /" on a live site. Build a safe file with the free Robots.txt Generator.

Jonathan Nwachukwu, founder of Assen Tools

Written by

Jonathan Nwachukwu · Founder & developer

Jonathan is a freelance web developer and web development teacher who builds Laravel, WordPress and WooCommerce sites for clients. He built AssenTools to put the everyday file, photo and calculation jobs he kept doing for clients and students into one free, private toolbox, and he maintains every tool and guide on the site.