How to Add llms.txt to WordPress: Complete Step-by-Step Guide
How to Add llms.txt to WordPress: Complete Step-by-Step Guide
WordPress powers 43% of all websites, making it the most important platform for llms.txt implementation. This guide shows you exactly how to add and optimize llms.txt on your WordPress site.
Why WordPress Sites Need llms.txt
Growing Importance
AI Search Traffic:
- 25% of searches now AI-powered
 - ChatGPT has 200M+ weekly users
 - Perplexity growing 50%+ annually
 - Early adopters gaining advantage
 
WordPress Advantages:
- Large content libraries
 - SEO-friendly structure
 - Easy plugin integration
 - Built-in XML sitemaps
 
Three Methods to Add llms.txt
Method 1: Plugin Installation (Easiest)
Best for: Non-technical users, quick setup
Step 1: Install Plugin
\\\`
1. Go to WordPress Admin → Plugins → Add New
2. Search for "LLMS Central Bot Tracker"
3. Click "Install Now"
4. Click "Activate"
\\\`
Step 2: Configure Settings
\\\`
1. Go to Settings → LLMS Central
2. Enter your site description
3. Select priority content
4. Click "Save Changes"
\\\`
Step 3: Verify Installation
Visit: \https://yoursite.com/llms.txt\
Plugin Features:
✅ Automatic llms.txt generation
✅ Bot tracking and analytics
✅ Auto-updates when content changes
✅ Dashboard widget
✅ No coding required
Method 2: Manual File Upload
Best for: Users who want full control
Step 1: Create llms.txt File
Create a text file named \llms.txt\:
\\\`
Your Blog Name
> Expert insights on [your niche]
Featured Content
- [Best Guide](https://yoursite.com/best-guide): Comprehensive tutorial
 - [Popular Post](https://yoursite.com/popular): Most-read article
 - [Case Study](https://yoursite.com/case-study): Real results
 
Blog Categories
- [Category 1](https://yoursite.com/category/cat1): Topic description
 - [Category 2](https://yoursite.com/category/cat2): Topic description
 
About
- [About Us](https://yoursite.com/about): Our story
 - [Contact](https://yoursite.com/contact): Get in touch
 
\\\`
Step 2: Upload via FTP
\\\`
1. Connect to your site via FTP (FileZilla, etc.)
2. Navigate to public_html or www folder
3. Upload llms.txt to root directory
4. Set permissions to 644
\\\`
Step 3: Verify
Visit: \https://yoursite.com/llms.txt\
Method 3: Code Snippet (Advanced)
Best for: Developers, dynamic content
Step 1: Install Code Snippets Plugin
\\\`
1. Install "Code Snippets" plugin
2. Activate plugin
3. Go to Snippets → Add New
\\\`
Step 2: Add Custom Function
\\\`php
// Generate llms.txt dynamically
add_action('init', 'serve_llms_txt');
function serve_llms_txt() {
if ($_SERVER['REQUEST_URI'] === '/llms.txt') {
header('Content-Type: text/plain; charset=utf-8');
$site_name = get_bloginfo('name');
$site_desc = get_bloginfo('description');
$site_url = home_url();
echo "# $site_name\n";
echo "> $site_desc\n\n";
// Get recent posts
echo "## Recent Posts\n";
$recent_posts = get_posts([
'numberposts' => 10,
'post_status' => 'publish'
]);
foreach ($recent_posts as $post) {
$title = $post->post_title;
$url = get_permalink($post->ID);
$excerpt = wp_trim_words($post->post_excerpt ?: $post->post_content, 15);
echo "- $title: $excerpt\n";
}
// Get categories
echo "\n## Categories\n";
$categories = get_categories(['hide_empty' => true]);
foreach ($categories as $cat) {
$name = $cat->name;
$url = get_category_link($cat->term_id);
$desc = $cat->description ?: "Articles about $name";
echo "- $name: $desc\n";
}
// About section
echo "\n## About\n";
echo "- About Us: Learn more about us\n";
echo "- Contact: Get in touch\n";
exit;
}
}
?>
\\\`
Step 3: Save and Activate
\\\`
1. Title: "Dynamic llms.txt Generator"
2. Click "Save Changes and Activate"
3. Test at yoursite.com/llms.txt
\\\`
Optimizing Your WordPress llms.txt
1. Content Selection
Priority Content to Include:
High-Value Posts:
\\\`php
// Get most popular posts
$popular_posts = new WP_Query([
'posts_per_page' => 10,
'meta_key' => 'post_views_count',
'orderby' => 'meta_value_num',
'order' => 'DESC'
]);
\\\`
Evergreen Content:
- Comprehensive guides
 - Tutorials and how-tos
 - Resource pages
 - Best practices
 
Recent Content:
- Latest blog posts
 - Updated articles
 - New resources
 - Current trends
 
2. Category Organization
Logical Structure:
\\\`
Main Topics
- [SEO](https://yoursite.com/category/seo): Search optimization guides
 - [Content Marketing](https://yoursite.com/category/content): Content strategies
 - [Analytics](https://yoursite.com/category/analytics): Data and insights
 
Resources
- [Tools](https://yoursite.com/tools): Free tools and calculators
 - [Templates](https://yoursite.com/templates): Downloadable templates
 - [Guides](https://yoursite.com/guides): Step-by-step guides
 
\\\`
3. Automatic Updates
Keep llms.txt Fresh:
\\\`php
// Update llms.txt when posts are published
add_action('publish_post', 'update_llms_txt_cache');
add_action('save_post', 'update_llms_txt_cache');
function update_llms_txt_cache($post_id) {
// Clear any caching
if (function_exists('wp_cache_flush')) {
wp_cache_flush();
}
// Regenerate llms.txt
// Your generation logic here
}
\\\`
WordPress-Specific Optimizations
1. Permalink Structure
SEO-Friendly URLs:
\\\`
Settings → Permalinks → Post name
✅ https://yoursite.com/post-title
❌ https://yoursite.com/?p=123
\\\`
2. XML Sitemap Integration
Reference Your Sitemap:
\\\`
Your Blog
> Description
Sitemap
- [XML Sitemap](https://yoursite.com/sitemap.xml): Complete site structure
 - [Post Sitemap](https://yoursite.com/post-sitemap.xml): All blog posts
 
\\\`
3. robots.txt Configuration
Allow AI Bots:
\\\`
WordPress robots.txt
User-agent: *
Allow: /wp-content/uploads/
Disallow: /wp-admin/
Disallow: /wp-includes/
AI Bots
User-agent: GPTBot
Allow: /
Crawl-delay: 1
User-agent: ClaudeBot
Allow: /
Crawl-delay: 1
User-agent: PerplexityBot
Allow: /
Crawl-delay: 1
Sitemap: https://yoursite.com/sitemap.xml
\\\`
Edit in WordPress:
- Use Yoast SEO or Rank Math
 - Or edit via FTP at root directory
 
4. Caching Considerations
Exclude llms.txt from Cache:
WP Rocket:
\\\`
Settings → Advanced → Never cache URL(s)
Add: /llms.txt
\\\`
W3 Total Cache:
\\\`
Performance → Page Cache → Never cache the following pages
Add: llms.txt
\\\`
Cloudflare:
\\\`
Page Rules → Create Page Rule
URL: yoursite.com/llms.txt
Setting: Cache Level = Bypass
\\\`
Tracking AI Bot Visits
Install Bot Tracking
Option 1: Plugin Method
\\\`
1. LLMS Central plugin includes bot tracking
2. View analytics in WordPress admin
3. Dashboard widget shows recent visits
\\\`
Option 2: JavaScript Widget
Add to theme's footer.php:
\\\`php
// Add before
