How to Host llms.txt on WordPress
Learn how to properly host your llms.txt file on WordPress so AI models can discover and understand your content
What You Need to Know
After generating your llms.txt file with llmstxt.studio, you need to host it at the root of your WordPress website
(e.g., https://yoursite.com/llms.txt
) so AI models can find it.
This guide covers multiple methods to add your llms.txt file to WordPress, from simple to advanced approaches.
Method 1: Upload via FTP or File Manager
Steps:
- Generate your llms.txt file using llmstxt.studio
- Access your WordPress files via:
- FTP client (FileZilla, Cyberduck, etc.)
- Your hosting control panel's File Manager
- cPanel File Manager
- Navigate to your WordPress root directory This is typically
public_html
,www
, or your domain folder - Upload the llms.txt file to the root directory It should be at the same level as your
wp-config.php
file - Verify by visiting
https://yoursite.com/llms.txt
Method 2: Using a Plugin
Option A: File Manager Plugin
- Install a file manager plugin like "File Manager" or "WP File Manager"
- Navigate to the root directory in the plugin interface
- Upload your llms.txt file
- Set permissions to 644 (readable by all)
Option B: Custom File Plugin
Use a plugin like "Custom Robots.txt" (which can handle any text file):
- Install and activate the plugin
- Create a new custom file entry for
/llms.txt
- Paste your llms.txt content
- Save and publish
Method 3: Add via functions.php
Add this code to your theme's functions.php
file:
// Serve llms.txt file
add_action('init', function() {
$request_uri = $_SERVER['REQUEST_URI'];
if ($request_uri === '/llms.txt') {
header('Content-Type: text/plain; charset=UTF-8');
// Your llms.txt content here
echo '# Your Site Name
> Your site description
## Documentation
- [Getting Started](https://yoursite.com/docs/start)
- [API Reference](https://yoursite.com/api)
## Tutorials
- [Quick Start Guide](https://yoursite.com/tutorials/quick-start)
';
exit;
}
});
To serve from an uploaded file:
// Serve llms.txt from uploads folder
add_action('init', function() {
if ($_SERVER['REQUEST_URI'] === '/llms.txt') {
$file_path = wp_upload_dir()['basedir'] . '/llms.txt';
if (file_exists($file_path)) {
header('Content-Type: text/plain; charset=UTF-8');
readfile($file_path);
exit;
}
}
});
Method 4: Using .htaccess (Apache Servers)
If your llms.txt is being blocked by WordPress, add this to your .htaccess
file:
# Allow direct access to llms.txt
<Files "llms.txt">
Order Allow,Deny
Allow from all
</Files>
# Place BEFORE WordPress rules
# BEGIN WordPress
Troubleshooting
- Check if the file is in the correct root directory
- Verify file permissions (should be 644)
- Clear any caching plugins
- Check if security plugins are blocking access
- Try the .htaccess method above
Add this to your .htaccess to force text display:
<Files "llms.txt">
ForceType text/plain
</Files>
- Whitelist
/llms.txt
in your security plugin settings - Check Wordfence, Sucuri, or similar plugin configurations
- Temporarily disable security plugins to test
- Add llms.txt to allowed files in firewall rules
Best Practices
Keep It Updated
Update your llms.txt file whenever you add significant new content or change your site structure.
Version Control
Keep a backup of your llms.txt file and track changes over time.
Test Accessibility
Regularly verify your file is accessible at /llms.txt
from different browsers.
Monitor Performance
Check your server logs to see if AI crawlers are accessing your llms.txt file.
Verify Your Installation
After uploading your llms.txt file:
- Direct Access Test: Visit
https://yoursite.com/llms.txt
- Content Verification: Ensure the file displays as plain text with proper formatting
- Crawler Test: Use tools like
curl
to verify:curl -I https://yoursite.com/llms.txt
Should return200 OK
status withContent-Type: text/plain
- AI Model Test: Ask an AI assistant about your site to see if it references your llms.txt content
Need to Update Your llms.txt?
As your WordPress site grows and changes, keep your llms.txt file current to ensure AI models have the latest information about your content.