It’s important to know how to optimize your WordPress robots.txt file to allow search engines to properly crawl and index your website while preventing access to sensitive areas.
A well-configured robots.txt file can improve your SEO performance by ensuring search engine bots focus on your valuable content and avoid wasting crawl budget on unnecessary pages.
This article will cover these questions to give you a correct and clear picture of the WordPress robots.txt file. From there, you can use the file to increase your online visibility in the SERPs or hide your sensitive content from the public.
We’ll start with the location of robots.txt, its examples, show ways to edit the file and conclude this post with how you should optimize WordPress robots.txt.
Where is the WordPress robots.txt file located?
The robots.txt file is located in the root directory of your website. Its main task is to instruct search engine bots how to crawl and index your site. In particular, it denies search engines access to certain files and folders.
Many WordPress site owners use the robots.txt file to prevent indexing by search engines. That sounds counterintuitive, right? Considering the fact that SEO, or reaching the top position on the SERPs, is a crucial component to the success of online businesses.
However, if your site is in development mode or contains low-quality or personal content, the robot.txt file proves useful for blocking the crawling and indexing of this content. From here, you can optimize your WordPress robots.txt file to prioritize your most important landing pages such as sales pages, product pages or sponsored posts.
In this context, you can also optimize your crawl rate. The crawl rate or crawl budget refers to the number of pages on your WordPress site that are crawled by Google bots at any given time. Allowing your important pages a crawl budget will help them to be indexed quickly and ranked on the first page of search results.
However, be sure to optimize the robots.txt file correctly, as it can hurt your SEO if done poorly.
WordPress Robots.txt example
You can see the robots.txt file of any website by adding /robots.txt to the end of the domain name. A robots.txt file will look something like this.

The user agent in a robots.txt file is the search engine that reads the robots.txt file. If the user agent is marked with an asterisk, this means that it gives the green light to all search engines.
In robots.txt files, the bots are told with allow and disallow which pages and content they may and may not crawl. As you can see, we have allowed search engines to crawl and index files in our WordPress admin Ajax and disallowed access to plugins and admin folders. A sitemap is an XML file that contains a list and details of all the pages on your website.
How to edit the Robots.txt in WordPress?
The easiest way to edit robots.txt in WordPress is to use plugins. There are several robust SEO plugins that help you edit the robots.txt file, such as All in one SEO and RankMath.
You can also seek help from plugins that are exclusively designed to optimize your WordPress robots.txt file such as Virtual Robots.txt, WordPress Robots.txt Optimization, and many more.
Alternatively, you can also edit the file manually using an FTP client. First, you need to connect to your WordPress hosting provider using an FTP client. Then search for the robots.txt file in the root directory of your website.

If you don’t see the robots.txt file there, chances are that it doesn’t exist on your website. Don’t panic, simply create a new file. Right-click, select “Create new file” and download it to your desktop.
Robots.txt is a plain text file, which means you can download it and edit it like other files using text editors such as Wordpad or Notepad.

Then update your changes, upload your edited robots.txt file back to the root folder and you’re done.
Test Your robots.txt file
You need to make sure that your robots.txt file works as usual after editing. If any errors occur, this can lead to your website being excluded from the search results pages.
Among the many tools for testing the robots.txt file, we recommend the Google Search Console, which allows you to test your robots.txt file for free.
Make sure that you have already submitted your website URL to Google Search Console so that the tool can verify your authentication. If not, read our guide on how to submit your site to search engines.
Then you can use the Google Search Console Robots Testing Tool. Once you’ve selected a property in the dropdown menu, the tool will go through the file and notify you if there are any errors or warnings.
In addition, you can use the tool to enter a specific page on your site and then select a specific user agent to check if that page is blocked or accepted for indexing.
How to optimize Your WordPress Robots.txt file for SEO
It is highly recommended to selectively disallow some of your sensitive pages such as /wp-admin/, /wp-content/plugins/, /trackback/ and /readme.html, while the rest remain “allowed”
In addition, you can optimize your WordPress robots.txt file by adding your sitemap to it. While WordPress provides its own sitemap, you can also use SEO plugins such as YoastSEO or Rank Math to create your own sitemap. They give you the option to create separate sitemaps for posts and pages.
If you then add these sitemaps to your robots.txt file, the bots can crawl faster and easier.
In truth, it is advisable not to change or revise the robots.txt file too much. Too many changes in the file can affect your page structure and prevent bots from crawling your site.
So, less is more. Just focus on your sitemap and make sure that your most important pages are discovered first.
Conclusion
Robots.txt is an important file that allows you to strategically optimize your crawl rate and hide private content from being indexed by search engines.
In this article, we have shown you what a robots.txt file is, where you can find it and how you can edit the file. We also showed you how to optimize your WordPress robots.txt file for SEO. The fewer entries in robots.txt, the better. And don’t forget to add a custom sitemap to the file to increase the visibility of your most important pages.