A copied robots.txt rule can block your best guide just as easily as an unwanted search page. The file may contain only a few lines, but those lines deserve more care than a quick paste from another website.
The difficult part is deciding what each rule should affect and checking that it stops there. A file that looks tidy can still block the images or scripts your pages need. The guide below shows how to restrict unwanted crawling while keeping those pages and files accessible, with checks to catch mistakes and a way to undo a bad change.
What Should Robots.Txt Do for SEO?
To optimize robots.txt for SEO, keep important pages and their supporting files crawlable, restrict selected unwanted URL patterns, include your sitemap address, and test the result.
Start by separating three jobs:
- Crawling means a search engine can request a URL and read its contents.
- Indexing means a search engine includes a page in its search index.
- Security means unauthorized visitors cannot access private content.
Robots.txt controls crawl access for crawlers that follow its instructions. It does not handle all three jobs.

A blocked page URL can still appear in Google. To exclude a public page from search, use a robots meta tag or an X-Robots-Tag response header containing noindex, and keep that page accessible to Google. Google does not support noindex inside robots.txt. Google’s indexing guidance explains this distinction.
Private customer records and paid downloads need authentication or another access control. Robots.txt is public, so listing a private folder there does not protect it.
For a smaller blog, I would fix access rules before trying to control how much Google crawls. A longer block list is not an achievement, and robots.txt changes do not guarantee indexing or better rankings.
1. Find and Back up Your Live Robots.Txt
Open your website’s root address followed by /robots.txt:
https://example.com/robots.txt
Save the current contents as a plain-text backup. Also record the address and response status. You can find the status in your browser’s developer tools under Network by reloading the file and selecting its request.
A successful response will normally show 200. A 404 means the file was not found, which ordinarily leaves Google with no robots.txt restrictions to apply. A timeout or server failure needs separate investigation.

Check the address carefully. Rules apply to the protocol, hostname, and port where the file is served. Your HTTPS file does not automatically govern HTTP, a separate shop subdomain, or another nonstandard port. These boundaries follow Google’s file-location requirements.
Next, find what controls the public response. It might be:
- A physical file in your website’s root folder.
- The content management system (CMS) you publish with, such as WordPress, or an SEO plugin.
- A hosting setting.
- A server setting or a content delivery network (CDN), such as Cloudflare, that serves files for your site.
On WordPress, I would check the existing SEO setup before installing anything else. If Rank Math already manages the file, work through that setup and verify the public result.
Know how to restore the saved version before editing. The backup needs to match the source that actually serves the file.
2. Decide Which URLs to Allow or Block
Add a restriction when you can name the problem it solves. Use URLs your site actually produces, and check crawl reports or server logs if they are available. Server logs record requests made to your website, including crawler visits.
For the running example, imagine your site publishes indoor-rabbit care guides and sells a printable care planner. The guides live under /guides/, the sales page is /care-planner/, and internal search results use /search/.

Write down the intended behavior before writing rules:
| URL or Pattern | Purpose | Intended Search Visibility | Crawl Decision | Reason |
|---|---|---|---|---|
/ | Introduces the site and links to key content | Eligible for search | Allow | Main entry point |
/guides/ | Contains useful care articles | Eligible for search | Allow | Readers discover the guides through search |
/care-planner/ | Sells the printable planner | Eligible for search | Allow | Important product page |
/category/housing/ | Groups useful housing guides | Eligible if the archive helps readers | Allow | Provides a useful browsing page |
/guides/page/2/ | Links to older guides | No separate indexing target here | Allow | Keeps older articles reachable |
/assets/ | Holds styles, scripts, and images | Supports page rendering | Allow | Google needs these files to understand pages |
/search/ | Generates internal search results | No search listing wanted | Block only if crawl restriction is the goal | Keep accessible if relying on noindex |
The last row requires a decision. If those search pages must stay out of Google, leave them crawlable and use noindex. The blocked-search example below assumes you have chosen to restrict crawling and understand that this alone does not guarantee removal from search.

Judge category, tag, and author archives by their usefulness. I would keep a well-organized archive that helps readers find related guides. I would skip automatic rules that block every archive simply because it is an archive.
Also check the files your pages load. I once copied a robots.txt template into a draft for a digital-product site and found that it blocked a stylesheet used by the sales page. The page URL passed my first check, but its supporting file failed. That is why I test assets alongside pages. Google specifically warns against blocking resources needed to understand a page in its robots.txt guidance.
Duplicate URLs need a different decision. Use a canonical tag to identify the preferred version, or redirect a retired duplicate to that version. Leave the relevant URLs crawlable so Google can read those signals. Google advises against using robots.txt for canonicalization.
3. Write Precise Robots.Txt Rules
Choose the Crawler Group
The basic fields have simple jobs:
User-agent:selects the crawler that should follow the group.Disallow:restricts matching URL paths.Allow:permits a matching path, usually as an exception to a broader restriction.
URLs remain crawlable unless an applicable rule blocks them. You do not need a separate Allow line for every guide.

Start with User-agent: * for shared rules. The asterisk here means the group applies when no more specific crawler group matches.
Add a crawler-specific group only when that crawler needs different access. Google chooses its most specific matching group and does not inherit the wildcard group’s restrictions. Repeated groups matching that specific crawler are combined. Google’s group-selection rules explain this behavior.

For example, if you add a separate Googlebot group, repeat any shared restrictions Googlebot still needs. Otherwise, a block that works for other crawlers may stop applying to Googlebot.
I would keep one shared group unless there is a clear reason to maintain more.
Match Unwanted Paths Narrowly
Write one directive per line. Start path values with /, and use # for comments explaining decisions that may be unclear later.
Field names are case-insensitive, but paths are case-sensitive. /Search/ and /search/ are different matches.
Pay particular attention to these two lines:
| Directive | Effect Within Its Crawler Group |
|---|---|
Disallow: | Adds no restriction |
Disallow: / | Blocks every path |
That single slash can change the whole file’s effect.

For the rabbit-care example, the narrow directory restriction is:
Disallow: /search/
It blocks /search/?q=hay and leaves /search-tips/ accessible. Using /search without the trailing slash would match both because both start with that text.
Two pattern characters help when a plain prefix is insufficient:
*matches zero or more characters.$marks the end of the match.
For example, /search$ matches /search, but not /search?q=hay. The query string matters when testing an end marker. These matching rules are defined in the Robots Exclusion Protocol.

If the search directory contains a help page that should remain crawlable, add an exception:
Disallow: /search/
Allow: /search/help.html$
Google uses the most specific matching path rule. Allow wins when conflicting rules are equally specific, and moving a line to the bottom does not make it override everything above it.
Avoid blanket query-string blocks such as Disallow: /*?. A question mark does not tell you whether a URL is useful. Review the actual parameter, its purpose, and the combinations your site generates.
For Google crawling, leave out unsupported fields such as Crawl-delay and Host. Extra lines do not make the file more effective.
Add the Sitemap Location
A sitemap lists pages for search engines, while a sitemap index links to several sitemap files. Find the file your site uses and open it to check that it lists the expected page URLs or sitemap links. Your CMS or SEO plugin may already generate one.
Add Sitemap: followed by its full address, including https:// and the hostname. This declaration is independent of crawler groups.

Here is the complete illustrative file for the rabbit-care site:
User-agent: *
Disallow: /search/
Sitemap: https://example.com/sitemap.xml
Replace the sitemap placeholder with your verified address. Remove the search restriction if your site does not use that path or you have chosen the crawlable noindex approach.

There are no explicit allowances for /guides/, /care-planner/, or /assets/ because this file does not block them.
Your existing rules may need more care than this short example. The AI Crawl Directive Assistant can prepare a site-specific draft and matching test URLs so you have something concrete to review before publishing.

Free AI Crawl Directive Assistant




Keep the sitemap focused on preferred URLs intended for indexing, and make sure those pages remain crawlable. Google’s sitemap guidance recommends listing the versions you want shown in search.
4. Test the Draft Before Publishing
Test the complete proposed file, including existing rules you plan to retain. Checking one new line in isolation can miss a conflicting group or exception.
Screpy’s robots.txt tester checks pasted drafts or the live file. To test unpublished rules, choose Paste robots.txt and paste the complete draft. Enter your site’s origin: the protocol and hostname, plus a port if your site uses a nonstandard one. Add the URL or path to check, select Googlebot, and run the test.
Read the matching group and deciding rule alongside the allowed or blocked result.
Use a small test sheet like this. The expected results below apply to the sample file; no tests have been run against your website.
| URL | Crawler | Expected Access | Actual Result: Current → Draft | Expected Deciding Rule |
|---|---|---|---|---|
/ | Googlebot | Allowed | Not tested | No matching restriction |
/guides/indoor-rabbit-enrichment/ | Googlebot | Allowed | Not tested | No matching restriction |
/care-planner/ | Googlebot | Allowed | Not tested | No matching restriction |
/assets/site.css | Googlebot | Allowed | Not tested | No matching restriction |
/assets/planner-preview.jpg | Googlebot | Allowed | Not tested | No matching restriction |
/sitemap.xml | Googlebot | Allowed | Not tested | No matching restriction |
/search/?q=hay | Googlebot | Blocked | Not tested | Disallow: /search/ |
/search-tips/ | Googlebot | Allowed | Not tested | /search/ does not match |

Run these checks against both the current file and the draft, then replace “Not tested” with the results. Investigate any changed access you did not intend.
Add tests for:
- Important JavaScript files and actual image URLs.
- Capitalization and trailing-slash variations your site generates.
- Query strings in their real positions and combinations.
- Every
Allowexception. - Existing crawler-specific groups and other relevant crawlers.
If you added the help-page exception, /search/help.html should be allowed, but /search/help.html?topic=hay should be blocked. The $ limits the exception to the URL without a query string. Test both to confirm that this is the behavior you want.
Resolve parsing warnings and unexpected results before publishing. A draft tester checks rule behavior; it cannot prove that Google can fetch your live website.
5. Publish and Check the Live File
Publish through the CMS, hosting control, or other source you identified earlier. If uploading a physical file, use UTF-8 plain text named exactly robots.txt at the relevant site root.
Then open its public address while logged out. Confirm that it returns the intended text and a successful response. A login screen, HTML error page, or security challenge is not the result you want, even if something appears in the browser.
If an older version appears, clear the relevant site or CDN cache and check again. For a site using Cloudflare, include its cache in that investigation.

Repeat your representative URL tests using the live file. The draft passing does not prove that the correct version was published.
Treat retrieval problems promptly. Google generally interprets 4xx responses other than 429 as having no robots.txt restrictions. Server failures and rate-limit responses have different handling and can interrupt crawling. Google documents those response rules here.
If an important page or asset becomes unintentionally blocked, restore the saved version immediately. Check the public response, correct the responsible rule in your draft, and repeat the tests before republishing.
6. Verify Access in Search Console
Open Search Console’s robots.txt report and check whether Google successfully fetched the file. Review parsing issues, the fetched contents, and the last fetch time.
The site you select in Search Console is called a property. This report works with a Domain property, covering a domain and its subdomains, or a URL-prefix property set to a site root, such as https://example.com/. If yours covers only a folder, such as https://example.com/guides/, switch to a site-level property.
After fixing a critical error or unblocking important URLs, request a robots.txt recrawl. Compare Google’s fetched contents with your deployment once the report updates. Your browser seeing the new file does not mean Google has refreshed its cached copy.

Next, inspect a representative guide and the planner sales page. Run Test live URL and review:
- Crawl allowed? should show permission for pages you want crawled.
- Page fetch should succeed.
- Indexing allowed? should permit indexing for pages intended for search.
- The tested page’s screenshot and resource details should show that essential content and supporting files load.
Read those results together. An indexing-permission result alone cannot prove that Google fetched the page successfully. Also distinguish the live test from the previously indexed version. A successful live check establishes access at test time and does not guarantee inclusion in search, as Google explains in its URL Inspection documentation.
Finally, review robots.txt exclusions in the Page indexing report. A newly blocked care guide needs attention. An intentionally restricted internal-search URL may be behaving exactly as planned.
Success means your intended access rules work, important pages and assets remain crawlable, the sitemap is discoverable, and robots.txt has no unresolved retrieval or parsing problems. Unrelated indexing issues need their own investigation.
Keep the backup, test sheet, and a short change log together. Record what changed and why. Recheck after changes to URL structures, themes, plugins, hosting, or the publishing system, and remove obsolete rules once you understand their original purpose.
What Next?
Save your live robots.txt and make a test list containing your homepage, one useful guide, one sales page, and their essential assets. Establish how those URLs behave before adding a restriction.
Use the social buttons to share this guide when a robots.txt edit is on the task list; the before-and-after checks can make that edit easier to review.
Which URL pattern on your site are you least sure about allowing or blocking? Leave it in the comments, along with any other questions.
Share this post with your friends & followers:
