Account

Guides

How to fix "Blocked by robots.txt" in WordPress

"Blocked by robots.txt" in Search Console means Googlebot checked your robots.txt before crawling a URL and the file did not allow it. Since WordPress 5.3 the "Discourage search engines" checkbox no longer writes to robots.txt: it adds a noindex tag, which Search Console reports as "Excluded by noindex tag". So a Disallow rule that closes the site usually comes from a physical robots.txt file or from an SEO plugin that writes one, and on older WordPress from the checkbox itself. The check on this page reads your live robots.txt and tells you whether it closes the whole site, how many Disallow rules it has and which sitemaps it lists.

Check your site

>
  1. Run the check on your robots.txt

    Enter your domain above. The checker fetches https://your-domain/robots.txt from outside your network and reports whether the file exists, whether a Disallow: / for all crawlers or for Googlebot closes the whole site, how many Disallow rules it has and which sitemaps it declares. If the whole site is closed, find where the rule comes from in steps 2 and 3. If the site is open but some URLs are still blocked, a narrower rule is the cause; go to step 4. If robots.txt is missing or empty, crawling is allowed and something else stops Google: look for a noindex tag, HTTP password protection or a firewall rule.

  2. Turn off the WordPress indexing block

    In wp-admin open Settings > Reading, uncheck "Discourage search engines from indexing this site" and save. The box often stays ticked after a staging copy goes live. Since WordPress 5.3 it adds a noindex tag to every page instead of a robots.txt rule, so it shows up as "Excluded by noindex tag" rather than "Blocked by robots.txt"; older versions served a virtual robots.txt with Disallow: /. Untick it either way, so it does not keep the site out of search once robots.txt is fixed.

  3. Check whether a real robots.txt file exists in the site root

    If the check shows the site as closed, the rule sits in a physical robots.txt file, which takes precedence over the virtual one WordPress serves. In your hosting control panel's file manager, turn on hidden files, open the folder where WordPress is installed (usually public_html) and look for robots.txt. Edit or delete it. SEO plugins such as Yoast, Rank Math and All in One SEO have their own robots.txt editor that writes this same file, so check there too. Only the file at the domain root counts; crawlers never read one in a subfolder.

  4. Make sure CSS and JS directories are not blocked

    Google renders a page before deciding what it is about, so it needs your stylesheets and scripts. Rules copied from old tutorials, such as Disallow: /wp-includes/ or Disallow: /wp-content/plugins/, break that rendering and should be removed. A safe minimal robots.txt for WordPress is:
    User-agent: *
    Disallow: /wp-admin/
    Allow: /wp-admin/admin-ajax.php
    Every line you add beyond these should have a reason you can explain.

  5. Declare the sitemap

    The check also reports whether a Sitemap line is present. Add one on its own line at the end of the file, with the full absolute address: Sitemap: https://your-domain/wp-sitemap.xml for the sitemap WordPress generates itself (5.5 and newer), or your plugin's sitemap address, which for Yoast and Rank Math is usually /sitemap_index.xml. The Sitemap line applies to all crawlers, whatever the User-agent blocks above it say.

  6. Re-run the check, then ask Google to revalidate

    When the check no longer reports the site as closed, purge your page cache, and the Cloudflare cache if you use Cloudflare, because a stale copy of robots.txt can keep being served for a while. Then in Search Console open Settings > robots.txt to see the version Google last fetched and request a recrawl. In the Page indexing report, open the "Blocked by robots.txt" issue and click Validate Fix. Google refetches robots.txt about once a day, and validation takes days.

How to verify the result

Open https://your-domain/robots.txt in a private window. It should show the rules you wrote and no Disallow: / line. Run the check on this page again: it should report the site as open to crawlers and find the Sitemap line. Search Console gives the final confirmation: run URL Inspection on your homepage and click Test live URL, which should report the URL as available to Google.

Tip: robots.txt only controls crawling. A blocked URL can still be indexed and appear in search results without a description if other sites link to it, which is what "Indexed, though blocked by robots.txt" means. For the same reason, do not try to remove a page from search with a Disallow rule: a crawler that cannot fetch the page never sees its noindex. To keep a page out of the index, allow crawling and serve noindex in a meta robots tag or an X-Robots-Tag header. Add the Disallow later, if you need it at all, once the URL has dropped out of the index.

Related guides