Your WordPress site already has a robots.txt file and it’s making decisions about what search engine crawlers can access, whether you’ve ever touched it or not.
Most of those decisions are harmless. But a single poorly chosen rule can also keep crawlers away from URLs you actually want them to discover.
In this guide, we’ll show you what your robots.txt file is doing right now how to edit it without touching code.

Here is everything we will cover in this guide:
What Is a Robots.txt File?
Robots.txt is a plain text file that tells search engine bots which parts of your site they can crawl.
The file lives in the root directory (the main folder) of your website. The basic format looks like this:
User-agent: [user-agent name]
Disallow: [URL string not to be crawled]
User-agent: [user-agent name]
Allow: [URL string to be crawled]
Sitemap: [URL of your XML Sitemap]
You can add as many rules and sitemaps as you need. If you do not disallow a URL, bots assume they can crawl it.
Your site works fine without a robots.txt file when you first start a blog. However, as your content grows, this file becomes more useful.
Search engines give each website a crawl budget, which is the number of pages they will crawl in a given timeframe. By blocking unimportant pages, you help bots spend that budget on the content you want in search results.
This matters most for large sites with thousands of pages.
Keep in mind that robots.txt helps you control crawling, not indexing.
- Crawling is when search engine bots (like Googlebot) visit your website to discover its content.
- Indexing is when they add that content to their massive search database so it can appear in search results.
Think of it like a librarian reading a new book (crawling) and then adding it to the library’s catalog (indexing).
In other words, robots.txt is also not a good way to hide content because a disallowed page can still appear in search results if other websites link to it. To reliably keep a page out of Google, use a ‘noindex’ meta tag instead. This tells search engines not to list the page at all.
Robots.txt Examples and Best Practices
For most WordPress sites, you can keep your robots.txt file fairly simple. Here is the basic setup we recommend:
User-Agent: *
Allow: /wp-content/uploads/
Allow: /wp-admin/admin-ajax.php
Disallow: /wp-admin/
Disallow: /readme.html
Disallow: /refer/
Disallow: /?s=
Sitemap: https://www.example.com/post-sitemap.xml
Sitemap: https://www.example.com/page-sitemap.xml
Here is what each rule does:
Allow: /wp-content/uploads/lets search engines crawl your images and other files uploaded to your WordPress media library.Allow: /wp-admin/admin-ajax.phpkeeps WordPress’s AJAX handler accessible. Themes and plugins may use this file to load or update content without refreshing the page.Disallow: /wp-admin/prevents crawlers from accessing your WordPress admin area, which doesn’t contain content you want appearing in search results.Disallow: /readme.htmlprevents crawlers from accessing WordPress’s defaultreadme.htmlfile. This file isn’t useful to search engines, so there is little reason for them to crawl it.Disallow: /refer/prevents crawlers from following affiliate or other redirect URLs that use the/refer/prefix. If your site uses a different prefix for these links, replace/refer/with your own.Disallow: /?s=prevents crawlers from requesting WordPress’s internal search URLs. These pages generally aren’t useful landing pages for search engines and can create many unnecessary URLs to crawl.Sitemaptells search engines where to find your XML sitemaps. This makes it easier for them to discover the URLs you want them to crawl.
These are the same core types of rules we use on WPBeginner. You can see our live file at wpbeginner.com/robots.txt. Our production file contains additional rules for a much larger site, but the basic principles are same.
Keep in mind that using the* wildcard applies to all crawlers.
For example, this rule blocks Googlebot from crawling the /private/ folder:
User-agent: Googlebot
Disallow: /private/
Common user agent names include Googlebot (Google), Bingbot (Bing), and Baiduspider (Baidu).
How to Create a Robots.txt File in WordPress
There are two ways to create a robots.txt file in WordPress. You can choose the method that works best for you.
Method 1: Editing Robots.txt File Using All in One SEO
Most free WordPress SEO plugins, like All in One SEO (AIOSEO), Yoast, or Rank Math, allows you to customize your robots.txt file right from your WordPress dashboard.
We use AIOSEO on WPBeginner. The free version of AIOSEO helps you validate your robots.txt rule as you type, which enables you to catch syntax errors before it goes live.
Once the plugin is active, simply go to All in One SEO » Tools in your WordPress dashboard. You will land on the Robots.txt Editor. Turn on the ‘Enable Custom Robots.txt’ toggle to start editing.

The editor shows the default rules that WordPress generates on its own.
Now you can add your own rules. Enter a user agent in the ‘User Agent’ field, or use * to apply the rule to all bots.
Then choose ‘Allow’ or ‘Disallow’ in the Directive column, and type the file or folder path in the ‘Value’ field. To add another rule, click the ‘Add Rule’ button.

You can check your finalized file in the ‘Custom Robots.txt Preview’ at the bottom of the screen. It shows the full file exactly as bots will see it.

When you are done, click the ‘Save Changes’ button to save your rules.
Method 2: Editing Robots.txt File Manually Using FTP
If you’d rather edit your robots.txt file directly, then follow this method. To edit the file, you will need to use an FTP client or the file manager in your WordPress hosting panel.
Before you edit anything, download a backup copy of your current robots.txt file to your computer. That way, you can restore it if something goes wrong.
First, connect your FTP client to your WordPress website and find the robots.txt file in your website’s root folder.

If you do not see one, your site does not have a robots.txt file yet. You can create one right there.
Robots.txt is a plain text file. You can download it, edit it in any plain text editor like Notepad or TextEdit, and upload it back to your root folder.
How to Test Your Robots.txt File
After creating or editing your robots.txt file, always check it for errors. A small typo can block important pages from search engines, and you may not notice for weeks.
The easiest way to test your robots.txt file for errors is with Google Search Console.
First, make sure your site is connected to Google Search Console. If it is not, follow our guide on how to add your WordPress site to Google Search Console.
Then go to your Search Console dashboard and open Settings from the bottom-left menu. Find the ‘Crawling’ section and click ‘Open Report’ next to ‘robots.txt’.

Click the current version of the file in the list. The report shows the latest robots.txt that Google has found, and it highlights any syntax errors or logical problems it detected.

If you just updated your file and the changes are not showing up, give it a day and then check it again.
Frequently Asked Questions About WordPress Robots.txt
Here are the most common questions readers ask us about optimizing the robots.txt file in WordPress.
1. Can using robots.txt improve my site’s security?
No, robots.txt is not a security measure. The file is publicly visible, so it doesn’t actually block anyone from accessing the URLs you list. It simply provides directives for well-behaved search engine crawlers.
2. Should I block WordPress category and tag pages in robots.txt?
No, you should not block category and tag pages. These archive pages carry internal links that crawlers follow to reach your older posts, so blocking them removes a discovery path for the content you do want indexed.
3. What’s the difference between robots.txt and the noindex tag?
They control different things. Robots.txt controls whether a crawler can visit a URL at all. The noindex tag controls whether search engines list a page in search results, even if they’ve already visited it.
Use robots.txt to block crawlers from areas like your admin panel, staging environment, or plugin directories. Use noindex for pages you’re fine with Google crawling, like filtered archive pages or thank-you pages, that you just don’t want appearing in search results.
We hope this article helped you learn how to optimize your WordPress robots.txt file for SEO. You may also want to see our ultimate WordPress SEO guide and our expert picks for the best WordPress SEO tools to grow your website.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.


Steve
Thanks for this – how does it work on a WP Multisite thou?
WPBeginner Support
For a multisite, you would need to have a robots.txt file in the root folder of each site.
Admin
Pacifique Ndanyuzwe
My wordpress site is new and my robot.txt by default is
user-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
I want google to crawl and index my content. Is that robot.txt okay?
WPBeginner Support
You can certainly use that if you wanted
Admin
Ritesh Seth
Great Airticle…
I was confused from so many days about Robots.txt file and Disallow links. Have copied the tags for robots file. Hope this will solve the issue of my Site
WPBeginner Support
We hope our article will help as well
Admin
Kurt
The files in the screenshots of your home folder are actually located under the public_html folder under my home folder.
I did not have a /refer folder under my public_html folder.
I did not have post or page xml files anywhere on my WP account.
I did include an entry in the robots.txt file I created to disallow crawling my sandbox site. I’m not sure that’s necessary since I’ve already selected the option in WP telling crawlers not to crawl my sandbox site, but I don’t think it will hurt to have the entry.
WPBeginner Support
Some hosts do rename public_html to home which is why you see it there. You would want to ensure Yoast is active for the XML files to be available. The method in this article is an additional precaution to help with preventing crawling your site
Admin
Ahmed
Great article
WPBeginner Support
Thank you
Admin
ASHOK KUMAR JADON
Hello, such a nice article you solve my problem. So Thank You so much
WPBeginner Support
Glad our article could help
Admin
Elyn Ashton
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php <– This is my robot.txt code but im confuse why my /wp-admin is index? How to no index it?
WPBeginner Support
If it was indexed previously you may need to give time for the search engine’s cache to clear
Admin
Ashish kumar
This website really inspire me to start a blog .Thank you lost of tema.this website each and every article have rich of information and explanation.when i have some problem at first i visit this blog . Thank You
WPBeginner Support
Glad our articles can be helpful
Admin
Anna
I am trying to optimise robots for my website using Yoast. However Tools in Yoast does not have the option for ‘File Editor’.
There are just two options
(i) Import and Export
(ii) Bulk editor
May you please advise how this can be addressed. Could it be that I am on a free edition of Yoast?
WPBeginner Support
The free version of Yoast still has the option, your installation may be disallowing file editing in which case you would likely need to use the FTP method.
Admin
Emmanuel Husseni
I really find this article helpful because I really don’t know much on how robot.txt works but now I do.
pls what I don’t understand is how do I find the best format of robot.txt to use on my site (I mean one that works generally)?
I noticed lots of big blogs I check ranking high on search engine uses different robot.txt format..
I’ll be clad to see a reply from you or just anyone that can help
Editorial Staff
Having a sitemap and allowing the areas that need to be allowed is the most important part. The disallow part will vary based on each site. We shared a sample in our blog post, and that should be good for most WordPress sites.
Admin
WPBeginner Support
Hey Emmanuel,
Please see the section regarding the ideal robots.txt file. It depends on your own requirements. Most bloggers exclude WordPress admin and plugin folders from the crawl.
Admin
Emmanuel Husseni
Thank you so much.
now I understand. I guess I’ll start with the general format for now.
jack
Well written article, I recommend the users to do sitemap before creating and enabling their ROBOTS text it will help your site to crawl faster and indexed easily.
Jack
Connie S Owens
I would like to stop the search engines from indexing my archives during their crawl.
Emmanuel Nonye
Thanks alot this article it was really helpful
Cherisa
I keep getting the error message below on google webmaster. I am basically stuck. A few things that were not clear to me on this tutorial is where do I find my site’s root files, how do you determine if you already have a “robots.txt” and how do you edit it?
WPBeginner Support
Hi Cherisa,
Your site’s root folder is the one that contains folders like wp-admin, wp-includes, wp-content, etc. It also contains files like wp-config.php, wp-cron.php, wp-blogheader.php, etc.
If you cannot see a robots.txt file in this folder, then you don’t have one. You can go a head and create a new one.
Admin
Cherisa
Thank you for your response. I have looked everywhere and can’t seem to locate these root files as you describe. Is there a path directory I can take that leads to this folder. Like it is under Settings, etc?
Devender
I had a decent web traffic to my website. Suddenly dropped to zero in the month of May. Till now I have been facing the issue. Please help me to recover my website.
Haris Aslam
Hello There Thank you For This Information, But I Have A Question
That I Just Create The Sitemap.xml and Robots.txt File, & Its Crawling well. But How Can I Create “Product-Sitemap.xml”
There is all list of product in sitemap.xml file. Do I Have To Create Product-sitemap.xml separately?
and submit to google or bing again ?
Can You please Help me out…
Thank You
Mahadi Hassan
I have a problem on robots.txt file setting. Only one robots.txt is showing for all websites. Please help me to show separate robots.txt file of all websites. I have all separate robots.txt file of all individual website. But only one robots.txt file is showing in browser for all websites.
Debu Majumdar
Please explain why did you include
Disallow: /refer/
in the beginner Robots.txt example? I do not understand the implications of this line. Is this important for the beginner? You have explained the other two Disallowed ones.
Thanks.
WPBeginner Support
Hi Debu,
This example was from WPBeginner’s robots.txt file. At WPBeginner we use ThirstyAffiliates to manage affiliate links and cloak URLs. Those URLs have /refer/ in them, that’s why we block them in our robots.txt file.
Admin
Evaristo
How can I put all tags/mydomain.Com in nofollow? In robots.txt to concentrate the link Juice? Thanks.
harsh kumar
hey,,i am getting error in yoast seo regarding site map..once i click on fix it ,,,it’s coming again..my site html is not loading properly
Tom
I’ve just been reviewing my Google Webmaster Tools account and using the Search Console, I’ve found the following:
Page partially loaded
Not all page resources could be loaded. This can affect how Google sees and understands your page. Fix availability problems for any resources that can affect how Google understands your page.
This is because all CSS stylesheets associated with Plugins are disallowed by the default robots.txt.
I understand good reasons why I shouldn’t just make this allowable, but what would be an alternative as I would suspect the Google algorithms are marking down the site for not seeing these.
Suren
Hi,
Whenever, I search my site on the google this text appears below the link: “A description for this result is not available because of this site’s robots.txt”
How, can i solve this issue?
Regards
WPBeginner Support
Hi Suren,
Seems like someone accidentally changed your site’s privacy settings. Go to Settings » Reading page and scroll down to ‘Search engine visibility’ section. Make sure that the box next to is unchecked.
Admin
Divyesh
Hello
As i seen in webmaster tool, i got robot.txt file like below :
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
let me know is that okey ? or should i use any other ?
John Cester
I want to know, does it a good idea to block (disallow) “/wp-content/plugins/” in robots.tx? Every time i remove a plugin it shows 404 error in some pages of that plugin.
Himanshu singh
I loved this explanation. As a beginner I was very confused about robot.txt file and its uses. But now I know what is its purpose.
rahul
in some robot.txt file index.php has been disallowed. Can you explain why ? is it a good practice.
Waleed Barakat
Thanks for passing by this precious info.
Awais Ahmed
Can you please tell me why this happening on webmaster tool:
Network unreachable: robots.txt unreachableWe were unable to crawl your Sitemap because we found a robots.txt file at the root of your site but were unable to download it. Please ensure that it is accessible or remove it completely.
robots.txt file exist but still
Dozza
Interesting update from the Yoast team on this at
Quote: “The old best practices of having a robots.txt that blocks access to your wp-includes directory and your plugins directory are no longer valid.”
natveimaging
Allow: /wp-content/uploads/
Shouldn’t this be?
Disallow: /wp-content/uploads/
Because you are aware that google will index all your uploads pages as public URLs right? And then you will get slapped with errors for the page itself. Is there something I am missing here?
nativeimaging
Overall, its the actual pages that google crawls to generate image maps, NOT the uploads folders. Then you would have a problem of all the smaller image sizes, and other images that are for UI will also get indexed.
This seems to be the best option:
Disallow: /wp-content/uploads/
If i’m incorrect, please explain this to me so I can understand your angle here.
Jason
My blog url not indexing do i need to change my robots.txt?
Im using this robots.txt
iyan
how to create robot txt which is ONLY allow index for page and Post.. thanks
Simaran Singh
I am not sure what’s the problem but my robots.txt has two versions.
One at http://www.example.com/robots.txt and second at example.com/robots.txt
Anybody, please help! Let me know what can be the possible cause and how to correct it?
WPBeginner Support
Most likely, your web host allows your site to be accessed with both www and non-www urls. Try changing robots.txt using an FTP client. Then examine it from both URLs if you can see your changes on both URLs then this means its the same file.
Admin
Simaran Singh
Thanks for the quick reply. I have already done that, but I am not able to see any change. Is there any other way to resolve it?
Martin conde
Yoasts blogpost about this topic was right above yours in my search so of course I checked them both. They are contradicting each other a little bit.. For example yoast said that disallowing plugin directories and others, might hinder the Google crawlers when fetching your site since plugins may output css or js. Also mentioned (and from my own experience), yoast doesn’t add anything sitemap related to the robots.txt, rather generates it so that you can add it to your search console. Here is the link to his post, maybe you can re-check because it is very hard to choose whose word to take for it
MM Nauman
As I’m Not Good in Creating this Robotstxt file So Can I use your Robots.txt file by changing the parameters like url and sitemap of my site is it good? or should I create a different one
Mohit Chauhan
Hi,
Today i got this mail from Google “Googlebot cannot access CSS and JS files”…what can be the solution?
Thanks
Parmod
Let me guess… You are using CDN services to import CSS and JS files.
or
It may be possible that you have written wrong syntax in these file.
Rahul
I have a question about adding Sitemaps. How can I add Yahoo and Bing Sitemap to Robots file and Wordpress Directory?
Gerbrand Petersen
Thanks for the elaborate outline of using the robots file. Does anyone know if Yahoo is using this robots.txt too, and does it obey the rules mentioned in the file? I ask this since I have a “Disallow” for a certain page in my file, but I do receive traffic coming from Yahoo on that page. Nothing from Google, as it should be. Thanks in advance.
Erwin
correction…
“If you are using Yoast’s WordPress SEO plugin or some other plugin to generate your XML sitemap, then your plugin will try to automatically add your sitemap related lines into robots.txt file.”
Not true. WordPress SEO doesn’t add the sitemap to the robots.txt
“I’ve always felt linking to your XML sitemap from your robots.txt is a bit nonsense. You should be adding them manually to your Google and Bing Webmaster Tools and make sure you look at their feedback about your XML sitemap. This is the reason our WordPress SEO plugin doesn’t add it to your robots.txt.”
https://yoast.com/wordpress-robots-txt-example/
Also more recommended is not to disallow the wp-plugins directory (reasons see Yoast’s post)
And personally I like to simply remover the readme.txt file…
hyma
I understood it robots.txt file and use of robots file. What is the site map how do I create sitemap for my site.
Rick R. Duncan
After reading Google’s documentation I’m under the impression that the directive to use in the robots.txt file is disallow which only tells the bots what they can and cannot crawl. It does not tell them what can and cannot be indexed. You need to use the noindex robots meta tag to have a page noindexed.
Nitin
really good article for seo optimized robots.txt file. But I need you to give a tutorial on how to upload robots.txt file to server. As, being a beginner it seems to be a drastic problem to upload that file.
By the way thanks to share such beneficial information.
-Nitin
Parmod
Upload it to your server/public_hmtl/(Your-site-name) … in this folder
Jenny
What is the best way to add code to HTTacess to block multiple spam bot refers for their url and Ip address if no URL is given
I know if you get wrong syntax when doing httacess it can take your site off line I am a newbie and need to block these annoying multiple urls from Russia, China, Ukraine etc.
Many thanks
Hazel Andrews
Thanks for those tips….robot txt files now amended! yay!
Rahat
why have to add Allow: !!!
if I mention only which have to Disallow that enough. Don’t have to write code for Allow because Googlebot or Bingbot will crawl all other thing automatically.
So why should I use Allow again?
Connor Rickett
Since lacking the Robots.txt file doesn’t stop the site from being crawled, I find myself curious: Is there any sort of hard data on exactly how much having the file will improve SEO performance?
I did a quick Google search, and didn’t see any sort of quantitative data on it. It’s about half a million articles saying, “Hey, this makes SEO better!” but I’d really like to know what we’re talking about here, even generally.
Is this a 5% boost? 50? 500?
WPBeginner Support
Search engines don’t share such data. While not having a robots.txt file does not stop search engines from crawling or indexing a website. However, it is a recommended best practice.
Admin
Connor Rickett
Thanks for taking the time to get back to me, I appreciate it!
JD Myers
Good timing on this. I was trying to find this information just yesterday.
The reason I was searching for it is that Google Webmaster tools was telling me that they could not properly crawl my site because I was blocking various resources needed for the proper rendering of the page.
These resources included those found in /wp-content/plugins/
After I allowed this folder, the warning disappeared.
Any thoughts on this?
WPBeginner Support
You can safely ignore those warnings. It is only a warning if you actually had content there that you would want to get indexed. Sometimes users have restricted search bots and have forgotten about it. These warnings come in handy in those situations.
Admin
Chetan jadhav
I have a question that many people out there use static sitemap, and you know what they have wordpress site. Should we us static or sitemap genrated by worpress.
Wilton Calderon
NIce, i like the way Wpbeginner have, and with that rank in alexa, look to me is one of the best way to sue robots.txt..
Brigitte Burke
what does my robots.txt file mean if it looks like this?
User-agent: *
Disallow: /wp-admin/
Disallow: /wp-includes/
Disallow: /xmlrpc.php
Editorial Staff
It’s just saying that search engines should not index your wp-admin folder, wp-includes folder, and the xml-rpc file. Sometimes disallowing /wp-includes/ can block certain scripts for search engines specially if your site is using those scripts. This can hurt your SEO.
The best thing to do is go to Google Webmaster Tools and fetch your website as a bot there. If everything loads fine, then you have nothing to worry about. If it says that scripts are blocked, then you may want to take out the wp-includes line.
Admin
hercules
I see no logic in your idea about having a script within the includes directory that can be used by a crawn / robot .. and another, if there is an isolated case, it is better after specify the default wordpress allow this file you imagine that search engines use his scripts! after all, wordpress has certainly not by default an robots.txt anti serch engines!!!!