DEV Community

Cover image for llm.txt: How to Make Your Wordpress Readable by AI Assistants
anti Gym Club
anti Gym Club

Posted on • Originally published at antigymclub.com

llm.txt: How to Make Your Wordpress Readable by AI Assistants

You've heard of robots.txt. It tells search engines what to crawl.

Now there's llm.txt. It tells AI assistants what your site is about.

The Problem

AI assistants like ChatGPT and Claude are becoming how people find information. But they work differently
than Google.

Google crawls your site, follows links, understands structure. AI assistants? They need explicit context.

Without it, they might:

  • Ignore your site entirely
  • Hallucinate wrong information about you
  • Recommend competitors instead

What is llm.txt?

A plain text file at yoursite.com/llm.txt that provides context to AI.

Basic structure:

Site Name

Brief description of what this site does

About

Detailed information about the site or business.

Key Pages

  • /about - About page
  • /products - Product listings
  • /blog - Technical articles

Products/Services

  • Product 1 - Description
  • Product 2 - Description

Contact

email@example.com

Human-readable. Machine-parseable. Takes 5 minutes to create.

Why It Matters

AI search is growing:

  • ChatGPT: 100M+ weekly users
  • Perplexity: 10M+ monthly users
  • Google AI Overviews: 30%+ of searches

These tools decide what content to surface. Without context, they skip you.

Implementation in WordPress

Option 1: Manual

Create llm.txt in your root directory:

  // In functions.php - serve llm.txt
  add_action('init', function() {
      if ($_SERVER['REQUEST_URI'] === '/llm.txt') {
          header('Content-Type: text/plain');
          echo file_get_contents(ABSPATH . 'llm.txt');
          exit;
      }
  });

Enter fullscreen mode Exit fullscreen mode

Then create the file manually and update it when you publish.

Option 2: Auto-generate

Query your posts and build the file dynamically:

  add_action('init', function() {
      if ($_SERVER['REQUEST_URI'] === '/llm.txt') {
          header('Content-Type: text/plain');

          $output = "# " . get_bloginfo('name') . "\n\n";
          $output .= "> " . get_bloginfo('description') . "\n\n";

          $output .= "## Recent Posts\n";
          $posts = get_posts(['numberposts' => 10]);
          foreach ($posts as $post) {
              $output .= "- " . get_permalink($post) . " - " . $post->post_title . "\n";
          }

          echo $output;
          exit;
      }
  });
Enter fullscreen mode Exit fullscreen mode

This keeps it updated automatically.

Option 3: Use a Plugin

If you want more control without writing code, https://antigymclub.com/plugins/llm-txt-generator-pro/ handles:

  • Auto-generation from all content types
    • Custom sections and context
    • Updates on publish
    • Preview before going live

Content Portability

Related problem: your content is trapped in WordPress's database.

For AI training, headless migrations, or proper backups, you need clean exports.

WordPress's native XML export is... not clean.

Better approach: export to JSON or Markdown.

  // Simple JSON export
  $posts = get_posts(['numberposts' => -1]);
  $export = [];

  foreach ($posts as $post) {
      $export[] = [
          'title' => $post->post_title,
          'content' => $post->post_content,
          'date' => $post->post_date,
          'url' => get_permalink($post)
      ];
  }

  header('Content-Type: application/json');
  echo json_encode($export, JSON_PRETTY_PRINT);
Enter fullscreen mode Exit fullscreen mode

For Markdown with frontmatter, you'll need to convert HTML content - more complex but doable.

Full Solution

I built two plugins that work together:

  1. LLM.txt Generator Pro - AI context file, auto-updated
  2. Content Exporter JSON/MD - Clean exports to JSON/Markdown

Available as the https://antigymclub.com/bundles/ai-readiness-bundle/ - $29 for both.

Getting Started

Minimum viable approach:

  1. Create llm.txt with your site description and key pages
  2. Upload to root directory
  3. Test: visit yoursite.com/llm.txt

That's it. AI assistants can now understand your site.

For automation, either write the code above or use a plugin.


Questions? Drop them in the comments.

Top comments (1)

Collapse
 
ali_muwwakkil_a776a21aa9c profile image
Ali Muwwakkil

A surprising insight is that most AI models like ChatGPT don't inherently understand the structure of web content -they rely heavily on cues like llm.txt to contextualize data. In our experience with enterprise teams, integrating llm.txt is more about guiding AI through your content's narrative rather than just permissions. This approach optimizes AI-agent responses by aligning them with your intended communication flow. - Ali Muwwakkil (ali-muwwakkil on LinkedIn)