How to Set Up Robots.txt in WordPress: Best Methods

WordPress is a powerful content management system that allows you to create and manage your website with ease. One important aspect of managing your website is controlling how search engines crawl and index your site. This is where the robots.txt file comes into play.

What is Robots.txt?

Robots.txt is a text file that tells search engine crawlers which pages or files on your website they can or cannot crawl. It acts as a guide for search engines, helping them understand your website’s structure and content.

By default, WordPress does not come with a robots.txt file. However, you can easily create and customize one to suit your needs. In this article, we will discuss the best methods to set up robots.txt in WordPress.

Method 1: Using a Plugin

One of the easiest ways to set up robots.txt in WordPress is by using a plugin. There are several plugins available that allow you to create and manage your robots.txt file.

Here are the steps to set up robots.txt using a plugin:

  1. Install and activate a robots.txt plugin from the WordPress plugin repository.
  2. Go to the plugin settings page and customize your robots.txt file.
  3. Save the changes and the plugin will automatically generate and update your robots.txt file.

Using a plugin is a beginner-friendly method as it does not require any coding knowledge. It provides a user-friendly interface to customize your robots.txt file according to your preferences.

Method 2: Manually Creating Robots.txt

If you prefer a more hands-on approach or want to have complete control over your robots.txt file, you can manually create it.

Follow these steps to manually create and set up robots.txt in WordPress:

  1. Access your website’s root directory via FTP or cPanel File Manager.
  2. Create a new text file and name it “robots.txt”.
  3. Edit the robots.txt file using a text editor.
  4. Add the necessary directives to allow or disallow specific crawlers or directories.
  5. Save the changes and upload the robots.txt file to your website’s root directory.

Manually creating robots.txt gives you full control over the file’s content and structure. You can specify which search engines or bots are allowed or disallowed from crawling specific parts of your website.

Important Directives for Robots.txt

When setting up your robots.txt file, it’s essential to include the following directives:

  • User-agent: Specifies the search engine crawler or bot to which the following directives apply.
  • Disallow: Instructs search engines not to crawl specific files or directories.
  • Allow: Overrides a disallow directive and allows search engines to crawl specific files or directories.
  • Sitemap: Indicates the location of your XML sitemap file.

By utilizing these directives, you can control how search engines crawl and index your website, ensuring that only relevant and valuable content is included in the search engine results.

Testing Your Robots.txt

Once you have set up your robots.txt file, it’s important to test it to ensure it is working correctly.

You can use the “robots.txt Tester” tool provided by Google Search Console to test your robots.txt file. This tool allows you to check if there are any syntax errors or issues with your file.

Simply submit your robots.txt file to the tool and test different user-agents and URLs to see if they are allowed or disallowed as intended.


Setting up robots.txt in WordPress is crucial for controlling how search engines crawl and index your website. Whether you choose to use a plugin or manually create the file, it’s important to include the necessary directives and regularly test your robots.txt to ensure it is working as intended.

Remember, a well-optimized robots.txt file can help improve your website’s visibility in search engine results and provide a better user experience for your visitors.

Ibraheem Taofeeq Opeyemi

I am a hard-working and help individual who isn't afraid to face a challenge. I'm passionate about my work and I know how to get the job done. I would describe myself as an open, and honest person who doesn't believe in misleading other people, and tries to be fair in everything I do. I'm Blogger | Website Designer | Website Developer | Content Writer | SEO Expert | Graphics Designer | WordPress Expert

Leave a Reply