Robots.txt Template for WordPress

This robots.txt keeps crawlers out of the admin area and the internal search pages, but allows the one admin file that many themes and plugins need on the front end.

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /?s=
Disallow: /search/

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

Here is the test of some paths for Googlebot:

Test result of the rules above

Googlebot /wp-admin/options.php Blocked
Googlebot /wp-admin/admin-ajax.php Allowed
Googlebot /?s=seo Blocked
Googlebot /search/seo/ Blocked
Googlebot /wp-content/uploads/2026/05/photo.jpg Allowed
Googlebot /blog/seo-guide/ Allowed

How it works

  • Disallow: /wp-admin/ blocks the admin folder, and the longer Allow rule makes an exception for admin-ajax.php.
  • /?s= and /search/ are the internal search result pages. They give no value in Google and waste crawling.
  • The images in /wp-content/uploads/ stay open, so Google can use them in image search.
  • Change the sitemap address to your own. If you use Yoast SEO or Rank Math, it is usually /sitemap_index.xml.
Note: Do not block /wp-content/ or /wp-includes/. Google needs the CSS and JavaScript from there to render your pages. See Robots.txt.

Learn more about the similar topics:
Tutorials
SEO – Canonical URLs
SEO – Robots.txt
SEO – XML Sitemap
Exercises & Assignments
Write a robots.txt file to block folders
Block all PDF files and URLs with a parameter in robots.txt
Add a canonical tag to a filtered page
Create an XML sitemap for three pages
Interview Questions & Answers
Which is more useful between an HTML sitemap and an XML sitemap?
What is technical SEO?
What is a robots.txt file?
What is an XML sitemap?
What is a canonical tag?
What is crawl budget?
What is duplicate content and how do you fix it?