Skip to content

Web Development

What Is robots.txt and How Does It Work?

robots.txt tells search engine crawlers which parts of your site to crawl. Learn how it works, example rules for WordPress and mistakes to avoid.

robots.txt file example for WordPress

Every day, search engine crawlers visit websites to discover content. A small text file called robots.txt tells them which areas they may crawl and which to skip. Used well, it keeps crawlers focused. Used badly, it can hide your whole site from Google.

What is robots.txt?

It’s a plain text file at the root of your domain — for example example.com/robots.txt. It contains rules for crawlers (called “user-agents”).

A typical WordPress example

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

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

  • User-agent: * — applies to all crawlers
  • Disallow — don’t crawl this path
  • Allow — exception inside a disallowed path
  • Sitemap — location of your sitemap

What it’s for

  • Keeping crawlers away from admin areas, internal search results or filter URLs
  • Reducing wasted crawling on large sites
  • Pointing crawlers to your sitemap

What it’s NOT for

  • Hiding pages from Google results — a blocked page can still appear if other sites link to it. Use a noindex tag instead.
  • Security — the file is public; never list secret URLs there. Protect private areas with logins.

Common mistakes

  • Disallow: / left over from development — blocks the entire site
  • Blocking CSS and JavaScript files Google needs to render pages
  • Blocking pages that also have noindex (Google can’t see the tag)
  • Typos in paths

How to edit it in WordPress

  • WordPress generates a virtual version automatically
  • Yoast SEO: Yoast SEO → Tools → File editor
  • Or upload a physical robots.txt file to your site’s root folder

How to test it

Use the robots.txt report in Google Search Console and the URL Inspection tool to check that important pages are crawlable. If pages disappear from Google, read why your website isn’t showing up on Google.

Key Takeaways

  • robots.txt tells crawlers which parts of your site to crawl.
  • It doesn’t hide pages from results — use noindex for that.
  • Never block your whole site or essential CSS and JS files.
  • Test your robots.txt in Google Search Console.

Further reading: Google Search Central: Introduction to robots.txt

Frequently Asked Questions About robots.txt

Does every site need one?
It’s recommended but not required. WordPress provides one automatically.

Can I block AI crawlers?
Many AI crawlers respect these rules for their user-agent names.

What if a page shows a 404 error?
That’s separate — see what is a 404 error.

Need a technical SEO check?

Makto Mine reviews crawl rules, sitemaps and indexing problems. Talk to us.

Related: What Are Core Web Vitals?

Leave a comment

Your email address will not be published. Comments are moderated before they appear.

Have a project in mind?

Tell us what your business needs. You will get a clear recommendation, a scope and a quotation — no obligation.