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

This is the most straightforward method and works with any WordPress hosting provider.

Steps:

  1. Generate your llms.txt file using llmstxt.studio
  2. Access your WordPress files via:
    • FTP client (FileZilla, Cyberduck, etc.)
    • Your hosting control panel's File Manager
    • cPanel File Manager
  3. Navigate to your WordPress root directory
    This is typically public_html, www, or your domain folder
  4. Upload the llms.txt file to the root directory
    It should be at the same level as your wp-config.php file
  5. Verify by visiting https://yoursite.com/llms.txt

Method 2: Using a Plugin

Option A: File Manager Plugin

  1. Install a file manager plugin like "File Manager" or "WP File Manager"
  2. Navigate to the root directory in the plugin interface
  3. Upload your llms.txt file
  4. 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):

  1. Install and activate the plugin
  2. Create a new custom file entry for /llms.txt
  3. Paste your llms.txt content
  4. Save and publish

Method 3: Add via functions.php

This method requires editing theme files. Always backup your site first!

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;
    }
});
OR

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
This ensures WordPress doesn't interfere with direct access to your llms.txt file.

Troubleshooting

404 Error when accessing llms.txt
  • 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
File downloads instead of displaying

Add this to your .htaccess to force text display:

<Files "llms.txt">
    ForceType text/plain
</Files>
Security plugin blocking access
  • 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:

  1. Direct Access Test:
    Visit https://yoursite.com/llms.txt
  2. Content Verification:
    Ensure the file displays as plain text with proper formatting
  3. Crawler Test:
    Use tools like curl to verify:
    curl -I https://yoursite.com/llms.txt
    Should return 200 OK status with Content-Type: text/plain
  4. 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.