Kern Media

★★★★★5.0Read our Google reviews ›
Talk to us: 303-594-6959 Request Consultation
  • Home
  • About
    • About Dan Kern
    • Reviews
    • Working With Us
    • Reporting
    • Switching Agencies
  • Services
    • LLM Optimization (GEO) & AEO Services
      • AI Visibility Audit
    • AI Overview & Traffic Recovery
    • Audits & Strategies
      • Technical SEO Audit
      • SEO Content Audit
      • Content Strategy
    • Lead Gen SEO & GEO
    • eCommerce SEO & GEO
    • Publisher SEO & GEO
    • CMS Platforms
  • Case Studies
  • AI Search Study
  • Blog
  • Pricing
  • Contact
You are here: Home / SEO & GEO Blog / How to Write a Robots.txt File (Including AI Crawlers)

How to Write a Robots.txt File (Including AI Crawlers)

October 4, 2026 by Dan Kern

Updated October 2026. I first wrote this guide in 2016. A lot has changed since then: Google dropped a few rules this post used to recommend, its testing tools were replaced, and AI crawlers from OpenAI, Anthropic, Perplexity and others now visit your site too. This version covers all of that.

A robots.txt file tells search engines and AI crawlers which parts of your site they can and can’t crawl. Get it right and bots spend their time on the pages that matter. Get it wrong and you can block your best pages from Google, ChatGPT and every other tool that might send you customers.

This guide uses WordPress examples, but the same rules work on any CMS once you account for its URL structure.

how to write a robots.txt file

What Is a Robots.txt File?

It’s a plain text file that lives at the root of your domain (for example, kernmedia.com/robots.txt). Crawlers check it before they crawl the rest of your site.

Two things to know up front:

  • Robots.txt controls crawling, not indexing. A blocked page can still show up in Google if other sites link to it. To keep a page out of search results, use a noindex tag instead (more on that below).
  • It’s a request, not a lock. Reputable crawlers follow it. Bad bots ignore it. Never use robots.txt to hide private content.

How Robots.txt Rules Work

Each group of rules starts with a User-agent line that names the crawler, followed by Disallow and Allow rules. An asterisk (*) means “all crawlers.”

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

A crawler follows the most specific group that matches its name. If you add a group for Googlebot, Googlebot follows that group and ignores the * group, so repeat any rules you still want it to follow.

Disallow a Specific URL

Disallow: /specific-url-here/

Disallow a Folder

Disallow: /subfolder/

Disallow URLs by Pattern

Google and Bing support two wildcards: * matches any characters, and $ marks the end of a URL.

Disallow: /*?s=
Disallow: /*.pdf$

Note: Be careful with wildcards. One broad rule can block pages you actually want crawled. Test every rule before it goes live.

Search Engine and AI Crawler User Agents

Here are the crawlers I see most often in client server logs, and what blocking each one does.

Search Engines

  • Googlebot: crawls for Google Search, including AI Overviews and AI Mode.
  • Bingbot: crawls for Bing, which also powers Microsoft Copilot and some other AI tools.
  • Google-Extended: not a separate crawler, but a robots.txt token that controls whether Google can use your content for Gemini models. Blocking it doesn’t affect your Google Search rankings.

OpenAI (ChatGPT)

Per OpenAI’s crawler documentation:

  • OAI-SearchBot: finds pages to show in ChatGPT search. Block this and your pages can’t be cited in ChatGPT search answers.
  • GPTBot: collects content for training OpenAI’s models. Blocking it doesn’t affect ChatGPT search.
  • ChatGPT-User: visits a page when a ChatGPT user asks it to. OpenAI says robots.txt rules may not apply here, since a person requested the visit.

Anthropic (Claude)

Per Anthropic’s crawler documentation:

  • ClaudeBot: collects content for training Claude models.
  • Claude-SearchBot: crawls to improve Claude’s search results. Blocking it can reduce your visibility in Claude’s answers.
  • Claude-User: fetches pages when a Claude user asks a question. Blocking it can keep your pages out of those answers.

Perplexity

Per Perplexity’s crawler documentation:

  • PerplexityBot: finds pages to show and link in Perplexity answers. It follows robots.txt.
  • Perplexity-User: visits pages when a user asks a question. Perplexity says it generally ignores robots.txt, since a person requested it.

Should You Block AI Crawlers?

For most of my clients, no. If you sell products or services, you want AI tools to read your pages, describe you accurately and link to you. In my AI search citation study, brands whose own website was cited in an AI answer were recommended 96% of the time, compared to 18% when their site wasn’t cited. Blocking the search crawlers works against you.

If you want to stay out of model training but still show up in AI search, block the training crawlers and allow the search ones:

User-agent: GPTBot
Disallow: /

User-agent: ClaudeBot
Disallow: /

User-agent: Google-Extended
Disallow: /

That still lets OAI-SearchBot, Claude-SearchBot, PerplexityBot, Googlebot and Bingbot crawl your site. Publishers who license their content have more reason to block training bots than an eCommerce store or service business does.

Tip: Robots.txt isn’t the only thing that can block AI crawlers. Firewalls, CDN bot settings (Cloudflare has an option to block AI bots) and security plugins can block them too. If you want AI visibility, check those settings as well.

Not sure which bots to allow or block?

On a free 30-minute call, we’ll talk through your site and goals.

Request a Free Consultation ›

What to Disallow on a WordPress Site

Less than you might think. The old advice (including from the first version of this post) was to block /wp-includes/, /wp-content/plugins/ and /wp-content/themes/. Don’t do that. Google needs to load your CSS and JavaScript to render your pages like a visitor sees them, and those folders hold those files.

Here’s what I’d usually block:

  • /wp-admin/ (but allow /wp-admin/admin-ajax.php, which some themes and plugins need)
  • Internal search results (/?s= and /search/), which can create endless low-value URLs
  • Private areas like a client portal or cart and account pages on an online store
  • Crawl traps like filtered and sorted URLs (see below)

Here’s the robots.txt file I use on this site:

# Kern Media robots.txt
# Search engines and AI crawlers are welcome. Admin and internal areas are excluded.

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

Sitemap: https://www.kernmedia.com/sitemap_index.xml

It’s short on purpose. Feel free to use it as a starting point, but change the private folders and sitemap URL to match your site.

Filtered URLs and Crawl Traps

Large sites, especially online stores, often create thousands of URLs from filters, sorting and session parameters (like ?color=blue&size=m&sort=price). Crawlers can waste a lot of time on these instead of your real pages.

Crawl your site with Screaming Frog and look for URL patterns that clearly aren’t pages you want in search results. Then write wildcard rules for them:

Disallow: /*?sort=
Disallow: /*&sort=

Before you block a filter, check Google Search Console. Some filtered pages (like a “red dresses” color filter) can bring in real search traffic, and you’d want to keep those crawlable.

Don’t Block Your Ad Landing Pages

Ad platforms crawl your landing pages to check them. If you use wildcard rules that could catch campaign tracking URLs (like ?utm_medium=), make sure you aren’t blocking them. Google’s ad crawler (AdsBot-Google) ignores the * group, so it only follows rules that name it directly.

Robots.txt Can’t Remove Pages from Google

This is the mistake I see most. If a page is already indexed and you block it in robots.txt, Google can’t crawl it anymore, which means it can’t see a noindex tag either. The page can stay in search results for a long time, often without a description.

To remove pages from Google:

  1. Make sure the pages are not blocked in robots.txt.
  2. Add a noindex meta robots tag (or an X-Robots-Tag HTTP header).
  3. Wait until Google has dropped them from its index.
  4. Then block them in robots.txt if you want to save crawl time.

The first version of this post suggested using a “Noindex” rule inside robots.txt. Google stopped supporting that in 2019, so don’t use it.

Link Your XML Sitemap

Add your XML sitemap at the bottom of the file so crawlers can find it. If you have more than one, list them all.

Sitemap: https://www.example.com/sitemap_index.xml

How to Test Your Robots.txt File

  • Google Search Console robots.txt report: found under Settings. It shows which robots.txt files Google found, when it last checked them and any errors. (It replaced the old Robots.txt Tester.)
  • URL Inspection tool: enter any URL to see if it’s blocked by robots.txt and how Google renders it. (It replaced “Fetch as Google.”)
  • Screaming Frog: lets you test a custom robots.txt file against your site before you publish it. This is the safest way to catch a rule that blocks too much.
  • Server logs: show which bots are actually visiting and whether they’re getting blocked. This is the only way to confirm AI crawlers are reaching your pages.

OpenAI notes it can take about 24 hours for ChatGPT search to pick up a robots.txt change, so give it a day before you test.

Need Help?

A robots.txt review is part of every technical SEO audit I do, along with JavaScript rendering checks for AI crawlers. If you have questions, contact me or request a free consultation.

Filed Under: SEO & GEO Blog

About Dan Kern

Dan Kern is a top Colorado SEO expert and Founder + Principal Consultant of Kern Media. He works closely with his clients to ensure their traffic gains meet their revenue goals. He enjoys business owners, entrepreneurs, company staff, and bloggers how to optimize their websites in a natural and compelling manner that both users and search engines value.

Dan Kern | SEO & GEO/AI Search Consultant ConsultantI’m Dan Kern, a veteran SEO & GEO consultant. I help established businesses scale revenue through "white hat" SEO, content marketing, and AI optimization. When you hire Kern Media, you work directly with me and my small team of experienced SEO professionals.

  • Proven Expertise: Google Analytics & Inbound Certified.
  • Search + AI Focus: Strategies built to rank on Google and get recommended by ChatGPT, Claude, and Gemini.
  • Trusted Consultant: Highly reviewed and rated 5.0 stars on Google.

Need Help? Let's talk. I'm for hire.

Qualifications & Certifications

Have confidence when hiring Kern Media for SEO consulting services. Dan Kern is Google Analytics Certified, Inbound certified, and featured with quality reviews amongst other top SEO agencies.

Follow Kern Media

Follow Kern Media on FacebookFollow Kern Media on TwitterFollow Kern Media on LinkedIn

What Clients & Colleagues Say

“Dan Kern has the unique mix of analytical and technical skills blended with creativity that mark a successful SEO these days. His expertise goes beyond “just” SEO in all its facets. Dan is also a solid marketing strategist with direct experience in most online marketing channels. I highly recommend working with him.” – Everett Sizemore

 

“I’ve just finished reviewing your technical SEO audit – it’s awesome. Thank you for taking the time to be thorough, clear and providing your personal commentary on items in the document.” – Ed Caraballo (Seer Interactive)

 

“I had the privilege of working with Dan for five years where he helped transform the way the company thought about and utilized SEO and inbound marketing. Traffic skyrocketed, increasing 7x over the course of six months.” – Winter Thielen

 

“Kern Media has provided only positive results for Costa Rica Explorations & Escapes since beginning our working relationship in 2012. Dan Kern continues to exceed our expectations on a daily basis as he works tirelessly to keep up with industry trends and keep our site optimized. “ – John Rabenau

 

“Not only is Dan admirable at his profession, but he’s also an incredible leader and teacher. He knows how to talk to someone to convey information clearly, and is driven by the goal of getting everyone educated and “on board” for a particular project or strategy.” – Corey Hartford

 

“Dan is by far, the most passionate about SEO and strategic content development of anyone I know. He takes each project on with determination for success and positive results. Dan is innovative, strategic, and results-focused, and there isn’t a responsibility that he doesn’t put his full energy into.” – Jill Simonds

 

“Dan uncovered several problem areas of our site, resulting in us being penalized by Google’s Panda algorithm, and contributing to decreasing organic growth. With his guidance, we were able to fix our SEO-problem areas and have since seen tremendous growth in our organic traffic year over year! He transformed not only this business, but provided a proven model with best practices we continue to employ today.” – Amanda Ferm

 

“In short, Dan is fantastic — a true SEO guru, who is also a pleasure to work with. He is diligent, creative and his excitement for SEO & Online Marketing is both deep and genuine.” – Dan Sargent

Need better visibility in Google + AI?

Work directly with Kern Media founder Dan Kern, an SEO and GEO consultant with 20+ years of experience.

We help established companies grow organic traffic, AI visibility, leads and revenue. Contact us or request a free consultation.

Consulting Services

  • SEO & GEO Services
  • LLM Optimization & GEO
  • AI Visibility Audit
  • eCommerce SEO & GEO
  • Lead Generation SEO & GEO
  • Technical SEO for Google & AI
  • Content Strategy for Google & AI
EXCELLENT
Google star 1Google star 2Google star 3Google star 4Google star 5
Based on 25 reviews
Google
Posted on Google Google
Amanda Ferm profile picture
Amanda Ferm
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
When Kern Media came in, they inherited nearly 30 years of accumulated SEO debt. Dan helped us untangle and clean up years of technical and content issues, build a much stronger SEO foundation, and ultimately allowed us to outrank our competitors for the most valuable keywords in our industry. What I appreciated most was that they didn't treat SEO as a static checklist. Their strategic appoach helped us understand how search was evolving, what changes actually mattered, and where we needed to adapt. As AI began reshaping search and discovery, they were already helping us think beyond traditional SEO and understand what emerging AI-driven search meant for our visibility. Kern Media brought both deep expertise and a practical, strategic approach to the work. They significantly improved our visibility while building a strong organic search foundation that positioned us to stay ahead of the curve as search continues to evolve—from traditional SEO to the rapidly changing world of AI-driven discovery.
Posted on Google Google
Keith Nickoles profile picture
Keith Nickoles
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
I have partnered professionally with Dan and his team at Kern Media for over five years, and their SEO strategies consistently deliver impressive results. I've never seen a system so detail-oriented. It's impressive to witness and be a part of. I strongly recommend their services to any business seeking a reliable, long-term partner for digital growth.
Posted on Google Google
Ashley Mo profile picture
Ashley Mo
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
Dan and the Kern Media team so impressed me with their expertise that he was my first call when I changed jobs and needed to hire an SEO consultant. Our organic traffic continues to grow as we've followed the content and technical recommendations from the team. Dan is great at explaining complicated terms simply and extremely responsive. I highly recommend working with Kern Media.
Posted on Google Google
Benjamin Smith profile picture
Benjamin Smith
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
Within minutes of talking to Dan he was able to help me troubleshoot a good deal why my search rankings were struggling. He has fantastic insight and truly is expert in the ever-changing world of SEO.
Posted on Google Google
Mike W profile picture
Mike W
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
Working with Dan has been a pivotal part of our company. For the past 10 years, we've been selling furniture online and have achieved early success in ranking well on Google. However, our pages were not structured to rank effectively. After our traffic began steadily declining, we decided to engage with Kern Media to improve our ranking and hopefully bring more traffic to the site. Our organic traffic has since more than doubled in less than a year. As the holiday season approached, Dan had the idea to come out with a Black Friday page and created a content brief for us to follow. Within a week, the page was ranking 3rd on Google for "Black Friday cat trees," which helped lead to a record-breaking Black Friday Sale. Kern Media has been quick to respond to questions, always available to talk through issues, and has been a pleasure to work with.
Posted on Google Google
Tim Hampton profile picture
Tim Hampton
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
Dan & Kern Media have been awesome to work with for many years. We've seen incredible growth with our organic results and have grown our keyword footprint immensely. Dan's technical acumen and knowledge of the "SEO" space is impressive. If you ever get the chance to work with Dan and Team, DO IT!!! Thank you for all that you have done and continue to do! We appreciate you, @Dan!
Posted on Google Google
Karen Johnson profile picture
Karen Johnson
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
Dan and his team came in and really changed the game for us. To date our organic results have grown 41%. He helped us clean up our site, add quality content and provided excellent guidance so we could continue to make improvements on our own. I highly recommend!
Posted on Google Google
Karyssa Cox profile picture
Karyssa Cox
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
Kern Media has been an incredible partner in developing my team's overall SEO strategy and implementing new tactics. We've worked with Dan on a number of different complex projects as well as ongoing consultation. Dan is on top of the latest SEO trends and best practices and always has ideas on how to ensure we're making the moves we need to in order to stay ahead. Dan's expertise and attention to detail have been crucial in completing our projects successfully, and he's also been great to collaborate with on how we can use SEO as a tool to achieve our overall goals. We've been very pleased and impressed with the results and are so grateful for the opportunity to work with Kern Media. Thanks, Dan and the Kern team!
Posted on Google Google
Sandra G profile picture
Sandra G
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
Dan and his team at Kern Media are truly SEO experts and our trusted advisors to us. Through their hard work our website, customer.com, is now of the first page of google search results for our area of expertise.

Kern Media
303-594-6959 Request Consultation
Kern Media on Twitter Kern Media on LinkedIn Kern Media RSS feed Kern Media on Facebook
About Services Contact AI Info Privacy Policy

© 2014–2026 Kern Media®. All rights reserved.