A robots.txt file is one of the smallest files on a WordPress website, yet one incorrect rule can keep search crawlers away from important pages. The goal is not to add clever commands everywhere. It is to understand what robots.txt does, check what your site currently serves, and change only the rules you can explain and test.
What robots.txt actually controls
Robots.txt gives cooperative crawlers instructions about which URLs they may request on a particular host. The usual location is https://example.com/robots.txt. Rules are grouped by User-agent and can include Allow and Disallow. Their interpretation depends on crawler support and the official robots.txt specification. A disallow rule is a crawling instruction, not a password, access-control mechanism, or guaranteed method of removing a URL from search results.
Google specifically explains that a blocked URL can sometimes still appear in search without a snippet when other websites link to it. If you need to keep private information private, protect it with authentication. If you want a crawlable page excluded from Google Search, use an appropriate noindex directive instead of assuming robots.txt will do the job. Read Google Search Central's robots.txt introduction before changing broad rules.
Find the file WordPress is serving now
Open the public /robots.txt URL in a private browser window. WordPress may provide a virtual robots.txt response; SEO plugins or server configuration can change it, and an actual file on the server may take precedence. Record the current text before editing. Check whether the response is accessible and whether it contains unexpected blanket blocks.
The first diagnostic question is not “How do I optimize this file?” but “Can search engines reach the pages I want them to discover?” Our guide to how search engines discover websites describes the wider process, while the SEO basics checklist helps you verify the fundamentals.
Understand a simple rule without copying it blindly
User-agent: *
Disallow: /example-private-path/
Allow: /
This illustrative example asks compliant crawlers to avoid one example path while generally allowing other paths. It is not a recommendation to add it to your website. WordPress installations, staging subdirectories and custom applications differ, and some crawlers do not honor every directive. A copied robots.txt file from an unrelated site can be actively harmful.
Four mistakes to avoid
- Blocking the whole site accidentally. A broad
Disallow: / can prevent compliant crawlers from fetching your pages. This can happen when staging settings move to production. - Trying to hide a page using robots.txt. Disallowing crawls does not enforce privacy and can prevent a crawler from seeing a page-level
noindex. - Blocking important CSS or JavaScript. Search engines may need resources to render the page accurately. Test consequences before disallowing asset paths.
- Assuming a sitemap entry overrides a block. A sitemap helps discovery, but it does not grant permission to crawl a disallowed page.
For the last point, pair this guide with our WordPress XML sitemaps guide. Sitemap quality and crawler access are related but distinct.
Should product pages or blog posts be disallowed?
Usually, if a product or article is intended to rank and attract visitors, blocking its URL from crawling works against that goal. Review actual site architecture instead of applying a blanket category rule. Product listings, variants, faceted navigation and filtered URLs require individual judgment; the right choice depends on whether each URL provides a useful, unique destination.
For WooCommerce, begin with our product-page SEO guide and check the mobile shopping journey in mobile SEO for WordPress. A URL that is technically accessible still needs useful content and a functional interface.
Use a testing workflow before publishing edits
- List priority URLs. Include the homepage, key guides, a representative article, a category page and a WooCommerce product.
- Check current robots.txt. Save its contents and inspect rules that match each priority URL.
- Check indexing separately. Use appropriate search-console diagnostics for indexing and live crawl access; they are different questions.
- Change one rule at a time. Prefer a backup or staging test, but remember staging crawlers may behave differently from live crawlers.
- Recheck the public response. Confirm the server serves the intended file and that caching does not show an older version.
- Monitor after deployment. Watch crawl reports, important landing pages and unexpected indexing changes.
Keep this workflow in your recurring SEO maintenance checklist. If a page still is not discovered, improve relevant internal links before assuming robots.txt is the only reason. A clear path through related pages helps people as well as crawlers.
Frequently asked questions
Does a robots.txt file improve rankings?
Not by itself. Its role is to guide crawler access. Useful content, discoverable links, reliable rendering and a good visitor experience still matter. Our useful-content guide covers that bigger picture.
Can I disallow a page and also use noindex?
Be careful: when Google is prohibited from crawling a URL, it cannot read the noindex directive on that page. Plan removal and access rules as separate tasks.
Should I edit robots.txt in MATRIX?
Use the actual SEO or server setting that controls the live robots.txt response on your installation. A visual page builder or mockup is not itself the file served to crawlers. Test the public URL after any change.
Next step: review sitemaps, audit your internal links and note any crawling issue before editing rules. Need assistance? Submit a question via Help, or discuss a site project with us through Contact.