Technical SEO guide

robots.txt in WordPress: what it does and how to edit it

By Anis Harbaoui, SEO specialist · Published 2 November 2026 · Updated 2 November 2026

robots.txt is a plain text file at the root of your site that tells crawlers which URLs they may and may not crawl. WordPress creates one for you on the fly. Most sites only need a few lines in it, and the most common mistake is asking it to do a job it was never built for: keeping pages out of Google.

Key takeaways
  • robots.txt controls crawling, not indexing. A blocked URL can still show up in search.
  • Google ignores noindex in robots.txt. Use a meta robots tag instead.
  • WordPress serves a virtual robots.txt until you upload a real file.
  • Never block the CSS and JavaScript your pages need to render.

What does robots.txt do?

It gives crawlers rules about which paths they may fetch. Google reads four fields: user-agent, allow, disallow and sitemap. A typical WordPress file looks like this:

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php

Sitemap: https://example.com/sitemap.xml

Google reads up to 500 KiB of the file and usually caches it for up to 24 hours, so a change can take a day to be picked up.

Does robots.txt stop a page from being indexed?

No. It only stops Google from crawling the page. If other pages link to a blocked URL, Google can still index the address and show it without a description.

To keep a page out of results, let Google crawl it and add a noindex rule. Our noindex guide for WordPress shows how. Blocking the same URL in robots.txt would hide the noindex tag from Google, so the two cancel each other out.

Where is the robots.txt file in WordPress?

By default it does not exist on disk. WordPress generates a virtual file when someone requests /robots.txt, and plugins can add lines to it. If you upload a physical robots.txt to the site root, the server sends that file instead and the virtual one is ignored.

Open yoursite.com/robots.txt in a browser to see what crawlers actually get.

How do you edit robots.txt in WordPress?

You have two options:

  1. Keep the virtual file and let WordPress and your plugins manage it. This is the safest choice for most sites.
  2. Upload a physical file to the site root through your host’s file manager or SFTP. You then own every line, including the Sitemap: line.

Whichever you pick, test the result in the robots.txt report in Google Search Console before you move on.

What should a WordPress site block?

Very little. Blocking /wp-admin/ while allowing admin-ajax.php is the usual default. WooCommerce stores often add cart and checkout parameters such as ?add-to-cart=.

Do not block /wp-content/ or /wp-includes/. Google needs your CSS, JavaScript and images to render the page the way visitors see it.

Should you block AI crawlers like GPTBot or ClaudeBot?

That is a business decision, not an SEO fix. Each AI company publishes its own user-agent, such as GPTBot, ClaudeBot or PerplexityBot, and you can allow or disallow each one by name. Google-Extended controls whether Google may use your content for its Gemini models. It does not change how you rank in Google Search.

If you want to be cited in AI answers, leave them open. Our guide on getting a WordPress site cited by AI search explains why.

How to do it with NexalSEO

NexalSEO does not edit robots.txt. It handles the jobs people wrongly give to robots.txt:

  1. To keep a page out of search, open it and switch on noindex in the Nexal SEO panel. The page also drops out of the sitemap.
  2. To fix a moved URL, add a 301 under Nexal SEO → Redirections instead of blocking the old path.
  3. Check the sitemap at /sitemap.xml and make sure your robots.txt points to it.

Frequently asked questions

Can robots.txt hide a page from Google?

No. It stops crawling, not indexing. Use a noindex meta tag and leave the page crawlable so Google can see it.

Does Google support noindex in robots.txt?

No. Google does not support a noindex rule in robots.txt. Put noindex in a meta robots tag or an X-Robots-Tag HTTP header.

How long does a robots.txt change take to apply?

Google generally caches robots.txt for up to 24 hours, so allow a day before checking again.

Should I block /wp-content/?

No. That folder holds the CSS, JavaScript and images Google needs to render your pages.

Related guides

Noindex in WordPress

Keep a page out of search the right way.

XML sitemaps in WordPress

What belongs in a sitemap and what does not.

Canonical tags

Handle duplicate URLs without blocking them.

Control indexing page by page

The NexalSEO WordPress SEO plugin gives every page a noindex switch and keeps noindexed URLs out of the sitemap automatically. Settings are in the sitemap documentation.

See the sitemap module