How to generate a robots.txt file
- Enter a user agent. Leave it empty for
*, which means all crawlers. - List the paths you want to allow, one per line. This is optional.
- List the paths you want to disallow, one per line.
- Add your sitemap URL. This is optional but recommended.
- Press Run tool and copy the result.
Every path must start with a slash and cannot contain spaces or a hash symbol. If you leave both lists empty, the tool writes Disallow: with nothing after it, which means "crawl everything".
A sensible robots.txt for WordPress
Most WordPress sites need very little. WordPress already serves a virtual robots.txt like this one:
User-agent: * Disallow: /wp-admin/ Allow: /wp-admin/admin-ajax.php Sitemap: https://example.com/wp-sitemap.xml
That is a good default. The admin-ajax.php line matters because some themes and plugins load content through it on the front end. If your SEO plugin creates its own sitemap, point the Sitemap line to that address instead, for example /sitemap_index.xml for Yoast SEO and Rank Math.
Robots.txt does not remove pages from Google
This is the most common misunderstanding. Robots.txt controls crawling, not indexing. If you block a page in robots.txt and other sites link to it, Google can still index the URL. It just shows it without a description.
To keep a page out of search results, let Google crawl it and add a noindex robots meta tag or an X-Robots-Tag header. If you block the page in robots.txt, Google never sees the noindex. You can check what a page currently sends with the indexability checker, and the WPSekar.com guide to removing noindex in WordPress covers the opposite problem.
Mistakes that hurt rankings
Disallow: /left over from development. This single line blocks the whole site. It happens most often after launching a site that was built on a staging server.- Blocking CSS and JavaScript. Old guides suggested blocking
/wp-includes/or/wp-content/plugins/. Google needs those files to render your pages, so do not block them. - Blocking pages you want removed. Use noindex instead, as explained above.
- Using robots.txt for security. The file is public. Listing a secret folder in it tells everyone where to look.
- Wrong file location. The file must sit at the root of the domain, such as
https://example.com/robots.txt. Each subdomain needs its own file.
Where to put the file
To replace WordPress's virtual file, upload a real robots.txt to your site's root folder through your host's file manager or SFTP. A physical file takes priority over the virtual one. Most SEO plugins also include a robots.txt editor, which is easier if you already use one. After saving, open /robots.txt in your browser to confirm it shows your changes. If you use a caching plugin or a CDN, clear the cache first.
Blocking AI crawlers
Some site owners use robots.txt to opt out of AI training crawlers. Generate one group per crawler by entering its user agent, such as GPTBot, and disallowing /. Then combine the groups in one file. Bear in mind that compliance is voluntary for every crawler.
Frequently asked questions
Does Google support Crawl-delay?
No. Google ignores it. Bing and some other crawlers respect it.
Are paths case sensitive?
Yes. /Private/ and /private/ are different paths.