Site Header — BloggingInsight

Robots.txt for SEO: What It Is and How to Create One

Google finds your pages by crawling them. But what if there are parts of your site you never want Google to crawl — your admin area, your internal search results, a staging copy of the site? Google will happily spend its time crawling those too, unless you tell it not to.

That is the job of robots.txt. It is a small text file that stands at the front door of your website and tells search engine crawlers which parts they may visit and which parts they must leave alone.

What is a robots.txt file?

A robots.txt file is a plain-text file that lives in the root folder of your website, so it is always found at yourdomain.com/robots.txt. Every well-behaved crawler checks it first, before it crawls anything else on your site.

The file is made of simple rule blocks. Each block names a crawler, then lists what that crawler may or may not do:

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://yourdomain.com/sitemap.xml

Read it line by line: the rules apply to every crawler (* means all of them); crawlers must stay out of /wp-admin/; one file inside that folder is still allowed; and the site’s sitemap lives at the address given.

Think of it as the guest list at the door. The sitemap is the map you hand Google once it is inside — robots.txt decides which rooms it is allowed to enter at all.

Why robots.txt matters

A robots.txt file does three jobs at once:

  • It protects your crawl budget. Google only spends so much time crawling any one site. Every minute it spends on admin pages, login screens, or filtered search results is a minute it does not spend on your real content.
  • It keeps private areas out of the crawl. Admin panels, cart and checkout pages, staging copies, and internal search pages should never be crawled. Robots.txt is the polite, standard way to say so.
  • It points crawlers to your sitemap. The Sitemap: line in robots.txt is the standard place to tell every crawler where your XML sitemap lives, so new pages get discovered faster.

A robots.txt file does not make a page rank. It makes sure Google spends its limited crawling time on the pages that can rank.

What goes in a robots.txt — and what does not

A good robots.txt blocks only the parts of the site that have no value in search:

  • Admin and login areas (/wp-admin/, /login/)
  • Cart, checkout, and account pages
  • Internal search results (/search?q=...)
  • Staging or test copies of the site
  • Files and folders that only your own team uses

It should never block:

  • Your homepage, blog posts, or product pages — anything you want in Google
  • Your CSS and JavaScript files — Google needs them to see the page properly, and blocking them can hurt how your pages are understood
  • Your XML sitemap — blocking the map defeats the point of having one

The golden rule: if a page should appear in Google, do not block it in robots.txt. If a page should never appear in Google, blocking it is only half the job — see the noindex note below.

Robots.txt blocks crawling, not indexing

This is the most misunderstood thing about robots.txt, and it catches beginners out:

  • Robots.txt stops crawling. Google will not visit a blocked page, so it cannot see what is on it.
  • It does not reliably stop indexing. A blocked page can still appear in Google’s results — usually with no description — if other pages link to it.

If you want a page gone from search results completely, use a noindex tag on the page instead. And here is the catch: for Google to see a noindex tag, the page must be crawlable. So a page with noindex must not be blocked in robots.txt. The two tools do opposite jobs, and mixing them up is one of the most common SEO mistakes there is.

How to create a robots.txt file

There are three common ways, from easiest to most hands-on:

  1. Use a generator. Build your rules in a form — pick a preset, add the folders to block, add the sitemap address — and download the finished file. This is the right choice for almost everyone, because the syntax is unforgiving: one stray slash can change what a rule means. Try the free Robots.txt Generator — it has presets for allow-all, block-all, and WordPress, and lets you add your sitemap in the same file.
  2. Let your SEO plugin do it. In WordPress, Rank Math and Yoast can create and edit the file for you from the dashboard, with no upload step.
  3. Write it by hand. Only sensible for a tiny site. One rule block per crawler, User-agent first, then Allow and Disallow lines, and a Sitemap: line at the end. Always test the result before you rely on it.

Whichever way you create it, upload the finished file to the root folder of your site so it is reachable at yourdomain.com/robots.txt. A robots.txt buried in a subfolder will never be found.

The 3-step check after you upload

  1. Open it in a browser. Visit yourdomain.com/robots.txt. It should show the exact rules you wrote — not an error page, not a login screen, and not an old version.
  2. Check it in Google Search Console. The robots.txt report shows how Google reads your file and flags any rule that blocks a page you wanted indexed.
  3. Check that your sitemap is listed. The file should end with a Sitemap: line pointing to your full sitemap address, starting with https://. If it is missing, add it — it is the fastest way to help crawlers discover new pages. Not sure your sitemap itself is valid? Run it through the free Sitemap Validator.

5 mistakes to avoid

  1. Blocking your whole site by accident. A single line — Disallow: / under User-agent: * — blocks every crawler from every page. This usually happens when a staging-site file is copied to the live site. If your whole site vanishes from Google after a redesign, check this line first.
  2. Blocking CSS and JavaScript. Google needs these files to render a page. Blocking them can make your pages look broken to Google, even though they look fine to visitors.
  3. Listing a blocked page in your sitemap. A sitemap says “crawl this page” while robots.txt says “do not crawl it”. Mixed signals waste crawl budget and confuse Google.
  4. Using robots.txt to hide a page from search results. Blocking stops the crawl, not the listing. Use a noindex tag instead — and keep the page crawlable so Google can see it.
  5. Setting it once and never checking again. Migrations, redesigns, and new plugins are the moments a robots.txt silently breaks. Check the live file after any of those, and check the Search Console report every few months.

Checklist before you publish

  • Only low-value areas are blocked — no real content pages
  • CSS and JavaScript files are not blocked
  • No blocked page is listed in your sitemap
  • A Sitemap: line points to your full sitemap address
  • The file opens correctly at yourdomain.com/robots.txt
  • Google Search Console reads the file the way you intended

Try it on your own site

Open yourdomain.com/robots.txt in a browser right now. Does it exist? Does it block anything you actually want in Google? And does it end with a Sitemap: line? If the file is missing — or if you are not sure what any of those lines mean — build a fresh one with the free Robots.txt Generator, upload it to your site’s root, and check it in Search Console. Five minutes now can save you from the silent mistake that removes a whole site from Google.