Robots.txt Example for WordPress: A Beginner’s Guide (2027)
A robots.txt example for WordPress is the fastest way to understand what this small but powerful file does. The robots.txt file tells search engine crawlers which parts of your site they may visit and which parts they should skip. Get it right and your site gets crawled efficiently. Get it wrong and you can accidentally block Google from your entire site.
This guide shows you a complete, copy-ready robots.txt WordPress example, explains every line in plain English, and walks you through editing it safely. You will also learn the most common mistakes beginners make and how to test your file before it causes problems.
What Is Robots.txt? A Simple Definition
Robots.txt is a plain text file that lives at the root of your website, at yourdomain.com/robots.txt. It gives instructions to search engine crawlers, also called robots or bots, about which pages they are allowed to crawl.
Think of it as a “staff only” sign on certain doors of your website. It does not lock the doors. It politely asks well-behaved crawlers not to enter. Google, Bing, and other major search engines respect these instructions.
Why WordPress Sites Need One
Every WordPress site generates pages you probably do not want in search results. Admin pages, login screens, search result pages, and tag archives can waste Google’s crawl budget or create thin, low-value indexed pages.
A good robots.txt file keeps crawlers focused on your real content: your posts, pages, and products — a basic WordPress SEO technical win. This is especially important for larger sites, where crawl budget is limited and every wasted crawl is a missed opportunity.
What Robots.txt Cannot Do
Robots.txt controls crawling, not indexing. Blocking a page in robots.txt does not remove it from Google’s index if it is already there. It only stops Google from visiting it again.
It also does not keep pages private. Anyone can type your robots.txt URL into a browser and read it. Never use robots.txt to hide sensitive information. Use proper authentication or noindex tags for anything that must stay private.
How Robots.txt Works in Plain English
When Google wants to crawl your site, it first requests your robots.txt file. It reads the rules, then crawls only the allowed areas. Here are the building blocks of those rules.
User-Agent: Who the Rule Applies To
Each rule block starts with a User-agent line. This names the crawler the rule applies to. A star (*) means all crawlers. You can also target specific ones, like Googlebot, if you need different rules for different search engines.
Disallow: What Crawlers Should Skip
The Disallow line lists URL paths crawlers should not visit. Disallow: /wp-admin/ tells crawlers to skip everything under your admin folder. Disallow: / with nothing after the colon blocks the entire site, which is almost never what you want on a live site.
Allow: Exceptions to Disallow Rules
The Allow line carves out exceptions. For example, you might disallow /wp-admin/ but allow /wp-admin/admin-ajax.php, which some themes and plugins need for front-end features. Allow rules override disallow rules for the specific paths they name.
Sitemap: Pointing Crawlers to Your Sitemap
The Sitemap line gives crawlers the URL of your XML sitemap. This helps them discover all your important pages quickly. Most SEO plugins generate this automatically, and you just reference it in robots.txt.
Robots.txt Example for WordPress (Copy-Ready)

Here is a safe, standard robots.txt example for WordPress that works for most blogs and small business sites. You can copy this as your starting point.
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /wp-includes/
Disallow: /wp-content/plugins/
Disallow: /wp-content/themes/
Allow: /wp-content/uploads/
Disallow: /trackback/
Disallow: /feed/
Disallow: /comments/feed/
Disallow: /?s=
Disallow: /*?
Sitemap: https://yourdomain.com/sitemap_index.xml
Replace yourdomain.com with your actual domain. The sitemap URL shown is the format used by popular SEO plugins like Rank Math and Yoast. If your plugin uses a different sitemap URL, update this line to match.
A Minimal Version for Simple Sites
If the full example feels like too much, this shorter version covers the essentials for most small WordPress sites.
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://yourdomain.com/sitemap_index.xml
This blocks the admin area, which is the main thing most sites need to block, while allowing everything else. It is a safe default. Add more rules only when you have a specific reason.
A Version for WooCommerce Stores
Online stores need a few extra rules to keep crawlers away from cart, checkout, and account pages.
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /cart/
Disallow: /checkout/
Disallow: /my-account/
Disallow: /*add-to-cart=*
Sitemap: https://yourdomain.com/sitemap_index.xml
These rules stop crawlers from wasting time on pages that are unique to each shopper and should never appear in search results.
Line-by-Line Explanation
Let us walk through the main example so you understand every line before you use it.
User-agent: *
This applies the following rules to all crawlers. Using the wildcard keeps things simple. You rarely need separate rules per search engine on a typical WordPress site.
Disallow: /wp-admin/
This robots.txt disallow rule blocks your WordPress dashboard and login pages. There is no reason for Google to crawl your admin area. It contains no public content, and crawling it wastes crawl budget WordPress sites should save for real content.
Allow: /wp-admin/admin-ajax.php
Some themes and plugins use this file to load content on your public pages. Blocking it can break features or prevent Google from rendering pages correctly. This allow rule makes sure it stays crawlable.
Disallow: /wp-includes/ and /wp-content/plugins/
These folders hold WordPress core files and plugin code. They contain no content worth indexing. Blocking them keeps crawlers focused on your actual pages. Note that blocking these folders does not block your images, which live in the uploads folder.
Allow: /wp-content/uploads/
Your media library lives here. You want Google to find your images, so this folder stays allowed. If you blocked your entire wp-content folder, you would also block images, which can hurt image search traffic.
Disallow: /?s= and /*?
These block WordPress internal search results and URLs with query parameters. Search result pages are thin, duplicate-heavy pages that should not be indexed. Blocking them at the crawl level prevents Google from wasting time on endless search combinations.
Sitemap Line
This sitemap robots.txt line tells crawlers exactly where your sitemap lives. It is a helpful hint, not a command. Crawlers can find sitemaps other ways, but stating it explicitly removes all doubt.
How to Edit Robots.txt in WordPress (3 Safe Methods)

Never edit robots.txt by guessing. Use one of these reliable methods, and always test afterward.
Method 1: Use Your SEO Plugin (Easiest)
Most SEO plugins include a robots.txt editor. In Rank Math, go to the dashboard and open the robots.txt editor. In Yoast, go to Tools and then File Editor. Paste your rules, save, and the plugin handles the rest.
This is the safest method for WordPress SEO for beginners. The plugin validates your syntax and manages the virtual file WordPress generates. You do not need FTP access or file permissions.
Method 2: Create a Physical File via FTP
Connect to your site with an FTP client or your host’s file manager. Navigate to your site’s root folder, the same folder containing wp-config.php. Create or edit the file named robots.txt.
A physical file overrides WordPress’s virtual one. This method gives you full control but requires care. A typo here affects your whole site, so double-check every line before saving.
Method 3: Use a Code Snippet (Advanced)
Developers can filter WordPress’s virtual robots.txt with code. This is useful when you want rules to change dynamically, such as on staging sites. Unless you are comfortable with PHP, stick with method one or two.
What to Do on a Staging Site
If you have a staging or development copy of your site, block all crawlers there. Use Disallow: / for every user agent on staging. This prevents Google from indexing your unfinished copy, which would create duplicate content problems.
Just remember to remove that block when you launch. Forgetting to unblock a site after migration is one of the most common and painful SEO mistakes.
Virtual vs Physical Robots.txt: What WordPress Uses
WordPress generates a virtual robots.txt file automatically if no physical file exists. When a crawler requests /robots.txt, WordPress builds the response on the fly with a few default rules.
The default virtual file is minimal. It typically allows everything except blocking nothing important. That is why most sites benefit from customizing it through a plugin or physical file.
If both exist, the physical file wins. WordPress serves the physical file and ignores the virtual one. When troubleshooting, always check whether a physical file exists first, since plugin edits will not take effect while one does.
What You Should and Should Not Block
Safe to Block
/wp-admin/— your dashboard and login pages- Internal search results (
/?s=) — thin, auto-generated pages - Tag and date archives, if they create thin duplicates on your site
- Cart, checkout, and account pages on stores
- Thank-you pages that only make sense after a form submission
Never Block
- Your CSS and JavaScript files — Google needs these to render pages correctly
- Your images folder (
/wp-content/uploads/) — blocking it kills image search traffic - Your entire site (
Disallow: /) on a live site — this removes you from search results - Important content pages, even if they underperform — fix the content instead
The CSS and JavaScript Trap
This deserves emphasis. Years ago, many guides recommended blocking theme and plugin folders entirely. But Google needs your CSS and JS to see your page the way visitors do. If it cannot render the page, it may misjudge your content.
The example in this guide blocks plugin and theme PHP folders but keeps uploads allowed. Modern best practice leans toward allowing CSS and JS freely. When in doubt, allow rendering resources.
Best Practices for WordPress Robots.txt
- Keep it simple. Most sites need fewer than 15 lines. Long, complex files are harder to maintain and easier to break.
- Test every change. Use the robots.txt tester in Google Search Console before and after editing. One bad line can block your whole site.
- Do not use robots.txt for private content. It is publicly readable. Use passwords or noindex tags for anything sensitive.
- Keep your sitemap line updated. If you change SEO plugins, verify the sitemap URL in robots.txt still matches the new plugin’s format.
- Review it yearly. Plugins, themes, and site structure change. An annual check catches outdated rules before they cause harm.
- Document your custom rules. Note why each non-standard rule exists. Future you, or your developer, will thank you.
7 Common Mistakes Beginners Make

- Blocking the entire site with
Disallow: /. This single line tells all crawlers to stay away from everything. It belongs on staging sites only. On a live site, it removes you from Google. - Blocking CSS and JavaScript. Google renders pages like a browser. Without your styles and scripts, it sees a broken page. Always allow the resources needed for rendering.
- Using robots.txt to hide private pages. The file is public. Anyone can read it, including people you do not want snooping. Use authentication for real privacy.
- Forgetting the staging block after launch. Developers block staging sites during builds. If that block carries over to the live site, rankings collapse. Check robots.txt immediately after every migration.
- Conflicting rules between plugin and physical file. If a physical robots.txt exists, plugin edits do nothing. Beginners edit in the plugin, see no change, and get confused. Check for a physical file first.
- Blocking paginated comment or archive pages incorrectly. Overly broad wildcards can block more than intended. Test wildcard rules carefully, since one stray asterisk can match hundreds of URLs.
- Never testing after changes. Every edit should be followed by a test in Search Console. Skipping this step is how small typos become site-wide disasters.
How to Test Your Robots.txt File

Step 1: View the Live File
Visit yourdomain.com/robots.txt in your browser. Confirm your changes are actually live. If you edited via a plugin but see old rules, a physical file or aggressive caching may be interfering.
Step 2: Use Search Console’s Tester
In Google Search Console, open Settings and find the robots.txt report. It shows the file Google last fetched and lets you test specific URLs against your rules. Enter important page URLs and confirm they show as allowed.
Step 3: Check Key Pages
Test your homepage, a blog post, a category page, and your sitemap URL. Then test a URL you intended to block, like /wp-admin/. Allowed pages should pass. Blocked pages should show as blocked. If anything surprises you, fix the rule before moving on.
Step 4: Monitor the Crawl Stats Report
After changes, watch Search Console’s crawl stats for a few weeks. A sudden drop in crawl requests can signal an accidental block. A rise in blocked-by-robots.txt URLs on important pages means a rule is too broad.
Real-World Examples: Good and Bad Files
Example 1: The Clean Blog Setup
A food blogger uses the minimal example from this guide: block /wp-admin/, allow admin-ajax.php, and reference the sitemap. Google crawls recipes efficiently, images appear in image search, and no admin pages leak into results. Simple and effective.
Example 2: The Store That Blocked Everything
A WooCommerce store owner copied a “block all bots” snippet from a forum onto the live site. Within weeks, product pages dropped from Google. The fix took five minutes: replace Disallow: / with the store example from this guide, then request re-indexing. Rankings recovered over the following month. The lesson: never copy robots.txt snippets without understanding each line.
Example 3: The Staging Site That Went Live
An agency launched a redesign but left the staging Disallow: / in place. The client noticed traffic falling two weeks later. A quick check of /robots.txt revealed the problem. Removing the block and submitting the sitemap in Search Console started the recovery. The lesson: checking robots.txt is step one after every launch or migration.
Robots.txt in 2027: What Changed
Google continues to emphasize rendering. Pages blocked from loading CSS and JS risk being misjudged. The trend is toward more permissive robots.txt files paired with noindex tags for pages you want crawled but not indexed.
AI crawlers are a new consideration. Various AI companies operate bots that train models or power answer engines. Some site owners now add specific user-agent rules for these bots. This is optional and depends on your stance toward AI training on your content. The major search crawlers remain the priority.
WordPress itself keeps evolving. Full-site editing and new default themes do not change robots.txt fundamentals, but they can change URL patterns. After major WordPress updates, verify that your rules still match your site’s actual structure.
Important Things to Consider Before You Start
Back up before editing. Whether you use a plugin or FTP, a backup lets you restore the previous file instantly if something goes wrong. Most hosts offer one-click backups.
Understand that robots.txt is a suggestion, not a lock. Well-behaved crawlers obey it. Malicious bots ignore it. If you are trying to stop scrapers, robots.txt alone will not do it. You need server-level protection for that.
Finally, keep perspective. For most small WordPress sites, the default setup plus blocking /wp-admin/ is enough. Do not over-engineer your file. Complexity creates risk, and a simple, tested file beats a clever, untested one every time.
Want crawlers to find the right pages? Explore more technical SEO guides on SearchEngineInsight.
Frequently Asked Questions
What is robots.txt in WordPress?
Robots.txt is a text file at yourdomain.com/robots.txt that tells search engine crawlers which parts of your site they may crawl. WordPress generates a basic virtual version automatically, but most sites benefit from customizing it to block admin pages, search results, and other low-value areas while keeping content crawlable.
Where is the robots.txt file in WordPress?
If it exists as a physical file, it lives in your site’s root folder alongside wp-config.php, accessible via FTP or your host’s file manager. If no physical file exists, WordPress generates a virtual one automatically. SEO plugins like Rank Math and Yoast provide built-in editors for the virtual version.
Can I copy the robots.txt example for WordPress in this guide?
Yes. The main example is designed as a safe starting point for most WordPress blogs and business sites. Replace the domain in the sitemap line with your own, then test the file in Google Search Console. Adjust the rules only if your site has special needs, like a store or membership area.
Does robots.txt affect SEO rankings directly?
Robots.txt affects crawling, which indirectly affects SEO. A good file helps Google spend its crawl budget on your important pages. A bad file can block Google from your content entirely, which removes those pages from search results. It does not boost rankings by itself, but mistakes here can destroy them.
Should I block wp-content in robots.txt?
Block the plugins and themes subfolders if you wish, but always allow the uploads folder. Your images live in uploads, and blocking them removes your images from Google Image Search. Never block your CSS and JavaScript files, since Google needs them to render your pages correctly.
What happens if I disallow everything in robots.txt?
Using Disallow: / tells all compliant crawlers to avoid your entire site. Google will stop crawling new pages and gradually drop your existing pages from search results. This rule belongs only on staging or development sites. If it appears on a live site by accident, remove it immediately.
How do I know if my robots.txt is blocking important pages?
Use the robots.txt tester in Google Search Console. Enter the URLs of your homepage, posts, and category pages to confirm they are allowed. Also review the Page Indexing report for pages marked as blocked by robots.txt. Any important page appearing there needs a rule fix.
Do I need a sitemap line in robots.txt?
It is recommended but not required. The sitemap line helps crawlers discover your XML sitemap quickly. Most SEO plugins generate the sitemap automatically, so you only need to reference its URL correctly. If you submit your sitemap directly in Search Console, the robots.txt line is a helpful backup.
Can robots.txt keep a page out of Google search results?
Not reliably. Robots.txt stops crawling, but Google can still index a blocked URL if other sites link to it, showing it without a description. To keep a page out of search results, allow crawling and use a noindex meta tag instead. Use robots.txt for crawl efficiency, not for hiding pages.
How often should I review my robots.txt file?
Check it after every site migration, redesign, or SEO plugin change, and review it at least once a year. Outdated rules are a common cause of crawl problems on growing sites. A quick annual review takes five minutes and prevents most robots.txt disasters.
Conclusion: Robots.txt Example for WordPress
A robots.txt example for WordPress does not need to be complicated. Start with the copy-ready example in this WordPress robots.txt guide, understand what each line does, and adjust only for your site’s specific needs. Block the admin area and junk pages, keep your content and images crawlable, and always point crawlers to your sitemap.
The two habits that prevent nearly all robots.txt disasters are testing every change in Search Console and checking the file after every migration or launch. Do those two things and this tiny text file will quietly do its job: keeping search engines focused on the pages that matter.