<!-- Generated from llms-txt-wordpress/index.html. The canonical document is the HTML page. -->

- [ Home ](/) 
/
- [ How to create llms.txt ](/how-to-create/) 
/
- WordPress            
# `llms.txt` in WordPress

Add an llms.txt file to your WordPress site in minutes. Three methods, pick the one that matches your hosting setup.

Last updated: April 22, 2026

On this page

- [ Three methods compared ](#overview)
- [ Method 1: FTP file upload ](#ftp)
- [ Method 2: Dynamic file via functions.php ](#functions-php)
- [ Method 3: .htaccess redirect ](#htaccess)
- [ Verifying the setup ](#verify)             
## Three methods compared

WordPress does not have a built-in way to serve arbitrary files at the domain root. Here are
three approaches, ordered from simplest to most powerful:

- **Method 1, FTP upload:** Upload `llms.txt` directly to the server root
via FTP/SFTP. No code required. Best for shared hosting and static content that rarely changes. 
- **Method 2, functions.php rewrite:** Register a custom WordPress rewrite rule that
serves a dynamically generated `llms.txt`. Best if you want the file to update
automatically when you publish new pages. 
- **Method 3, .htaccess redirect:** Redirect `/llms.txt` to a static file
or another URL using Apache\'s `.htaccess`. A useful fallback when you cannot
upload directly to the root.   
## Method 1: FTP file upload

This is the simplest and most reliable method. WordPress is installed at the root of your domain
(or a subdirectory), and anything you place in that folder is served by the web server directly,
without going through WordPress at all.

- **Write your `llms.txt` file.** Use the [generator](/generator/)
to create the file, or write it by hand following the
[how-to guide](/how-to-create/). Save it locally as `llms.txt`. 
- **Connect via FTP/SFTP.** Use FileZilla, Cyberduck, or your hosting control panel\'s
file manager. Connect to your server. 
- **Navigate to the WordPress root.** This is the folder that contains
`wp-config.php`, `wp-content/`, and `index.php`. 
- **Upload `llms.txt`** to that folder. 
- **Verify:** Visit `https://yourdomain.com/llms.txt` in a browser. You should
see plain text.     
Example

Managed WordPress hosting

On managed WordPress hosts (WP Engine, Kinsta, Flywheel, Cloudways), you typically have SFTP
access. Connect and upload to the root directory. If your host uses a CDN with object storage
(like Cloudflare R2 or AWS S3) for static assets, check whether you need to place the file there
instead.

## Method 2: Dynamic file via functions.php

If you want `llms.txt` to be generated dynamically from your WordPress content, for example,
listing your most recent posts or key pages automatically, you can hook into WordPress\'s rewrite
system.

Add the following to your theme\'s `functions.php` or a site-specific plugin:

```
/**
* Serve a dynamic /llms.txt via WordPress rewrite.
*/
add_action( 'init', function() {
add_rewrite_rule( 'llms\.txt$', 'index.php?llms_txt=1', 'top' );
} );

add_filter( 'query_vars', function( $vars ) {
$vars[] = 'llms_txt';
return $vars;
} );

add_action( 'template_redirect', function() {
if ( ! get_query_var( 'llms_txt' ) ) {
return;
}

$site_name = get_bloginfo( 'name' );
$site_url  = home_url();
$desc      = get_bloginfo( 'description' );

// Build a curated list, customize as needed
$pages = [
[ 'title' => 'Home',    'url' => home_url( '/' ),          'desc' => 'Site entry point.' ],
[ 'title' => 'Blog',    'url' => home_url( '/blog/' ),      'desc' => 'Latest articles.' ],
[ 'title' => 'About',   'url' => home_url( '/about/' ),     'desc' => 'About this site.' ],
[ 'title' => 'Contact', 'url' => home_url( '/contact/' ),   'desc' => 'Contact form.' ],
];

$lines   = [];
$lines[] = "# ${site_name}";
$lines[] = '';
$lines[] = "> ${$desc}";
$lines[] = '';
$lines[] = '## Core pages';
$lines[] = '';
foreach ( $pages as $page ) {
$lines[] = "- [${$page['title']}](${$page['url']}): ${$page['desc']}";
}
$lines[] = '';

header( 'Content-Type: text/plain; charset=utf-8' );
echo implode( "\n", $lines );
exit;
} );

```

After adding this code, go to **Settings → Permalinks** in the WordPress admin and click
**Save Changes** to flush the rewrite rules. Then visit
`/llms.txt` to confirm it works.

Warning

Child theme or site-specific plugin recommended

Do not add this code to a parent theme\'s  functions.php , your changes will be
overwritten on the next theme update. Use a child theme or a simple site-specific plugin (a
single-file plugin in  wp-content/plugins/my-llms-txt/my-llms-txt.php ).

## .htaccess redirect

If you cannot upload a file to the root directly, but you can edit `.htaccess`, you
can redirect `/llms.txt` to any other URL (including an uploaded file elsewhere on your
server, or an external URL).

Add the following to your `.htaccess` file, **before** the WordPress rewrite
block:

```
# llms.txt redirect, place BEFORE the WordPress block
RewriteEngine On
RewriteRule ^llms\.txt$ /wp-content/uploads/llms.txt [L,R=301]

```

This redirects `https://yourdomain.com/llms.txt` to a file you\'ve uploaded via the WordPress
Media Library (or manually placed in `wp-content/uploads/`). Note that redirecting
with a 301 means the actual file URL will be visible to users and bots, that is fine for most
use cases.

If you want to serve the file without a redirect (at the canonical `/llms.txt` URL), Method
1 (FTP) or Method 2 (rewrite rule) is preferable.

## Verifying the setup

Regardless of which method you use, verify the result:

- Visit `https://yourdomain.com/llms.txt`, you should see plain text with no HTML
wrapper. 
- Run: `curl -I https://yourdomain.com/llms.txt` and check for `200 OK` and
`Content-Type: text/plain`. 
- Paste the URL into the [llmtxt.info validator](/validator/) to confirm spec compliance. 
- Confirm `llms.txt` is not accidentally blocked in your `robots.txt`.   
## Continue reading

- [How to create llms.txt](/how-to-create/), general guide with format reference. 
- [Generator](/generator/), fill a form and download your file. 
- [Best practices](/best-practices/), what to include for maximum usefulness. 
- [llms.txt and SEO](/llms-txt-seo/), what it does and does not do for rankings.         
## Sources

- [ llmstxt.org, spec reference ](https://llmstxt.org/)
- [ WordPress, add_rewrite_rule() documentation ](https://developer.wordpress.org/reference/functions/add_rewrite_rule/)
