# Adding llms.txt to WordPress

> Three ways to add llms.txt to WordPress: upload it to the web root, generate it with a rewrite rule in functions.php, or use a plugin. Then check it is live.

Source: https://llmstextgenerator.com/llms-txt-wordpress/
Last updated: 17 October 2026

WordPress makes this slightly awkward, because the admin interface cannot write to the root directory. Three approaches, from simplest to most maintainable.

**The quickest way to add llms.txt to WordPress is to upload the file to the folder that holds `wp-config.php`.** If your content changes often, generate it from your pages with a rewrite rule instead, so it can never go stale.

## Option 1: upload the file (simplest)

Generate the file, then put it in the WordPress root: the directory containing `wp-config.php` and `wp-content`, not inside a theme folder.

1. Build your file with the [generator](https://llmstextgenerator.com/#generator) and save it as `llms.txt`.
2. Connect over SFTP, or open your host’s file manager.
3. Upload it to the root, next to `wp-config.php`.
4. Visit `https://yoursite.com/llms.txt` to confirm.

**Do not put it in your theme directory.** It ends up at `/wp-content/themes/yourtheme/llms.txt`, which nothing will look for, and it disappears the next time the theme updates.

## Option 2: generate it dynamically

Better for sites that change often, because the file cannot go stale. Add this to your child theme’s `functions.php` or a small site-specific plugin. It uses the [WordPress rewrite API](https://developer.wordpress.org/reference/functions/add_rewrite_rule/):

functions.php

```
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;
    }

    header( 'Content-Type: text/plain; charset=utf-8' );

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

    $pages = get_pages( array( 'sort_column' => 'menu_order' ) );
    if ( $pages ) {
        $out .= "## Pages\n";
        foreach ( $pages as $page ) {
            $summary = $page->post_excerpt
                ? $page->post_excerpt
                : wp_trim_words( wp_strip_all_tags( $page->post_content ), 22, '' );
            $out .= sprintf( "- [%s](%s): %s\n",
                $page->post_title, get_permalink( $page ), $summary );
        }
    }

    echo $out;
    exit;
} );
```

Visit **Settings › Permalinks** once after adding this and click Save. That flushes the rewrite rules; without it you will get a 404.

Treat the output as a starting point. Descriptions built from excerpts are serviceable but generic; the [best practices guide](https://llmstextgenerator.com/llms-txt-best-practices/) explains why hand-writing the important ones matters.

## Option 3: a plugin

Several plugins now generate llms.txt, and some SEO plugins have added it. They are convenient if you would rather not touch code. Two cautions: check the plugin is actively maintained before adding another dependency for one small text file, and check what it actually outputs. Several dump every published post, which produces exactly the uncurated file you want to avoid.

## Do Yoast, Rank Math, AIOSEO or SEOPress create llms.txt?

**Yes, all four can, and three of them in their free versions.** If you already run one of these SEO plugins, turn its llms.txt feature on rather than installing another plugin. According to each plugin’s own changelog and documentation (checked 17 October 2026):

| Plugin | Since | Free? | Where the setting is |
| --- | --- | --- | --- |
| Yoast SEO | 25.3 (June 2025) | Yes, off until you turn it on | Yoast SEO, Settings, Site features, AI tools, LLMS.txt |
| Rank Math | 1.0.250 (July 2025) | Yes | Enable the LLMS Txt module, then General Settings, Edit llms.txt |
| All in One SEO | 4.8.4 (June 2025) | Yes, on by default | All in One SEO, Sitemaps, LLMs.txt tab |
| SEOPress | 9.5 (January 2026) | No, PRO only | SEO, PRO, llms.txt tab |

Plugins like these typically serve a *virtual* file that WordPress builds on request (SEOPress says so in its guide), so nothing is written to disk. If you also uploaded a real `llms.txt` to the web root, the web server normally serves the real file before WordPress sees the request and the plugin’s settings appear to do nothing, so keep one or the other. Yoast notes its feature is not available on multisite. Whichever you use, open the result and trim it to the pages that matter.

## How do you check it is live?

- Open `https://yoursite.com/llms.txt` in a private window. You should see raw text, not a themed page.
- Confirm the content type is `text/plain`, not `text/html`. Caching plugins sometimes change this.
- Check `https://yoursite.com/robots.txt` is not disallowing it, with the [tester](https://llmstextgenerator.com/robots-txt-tester/) ([Google’s robots.txt introduction](https://developers.google.com/search/docs/crawling-indexing/robots/intro) explains the rules).
- Run it through the [validator](https://llmstextgenerator.com/llms-txt-validator/).

If you use a page cache or a CDN, purge it after uploading. A cached 404 is the most common reason a correctly uploaded file appears to be missing.

## Frequently asked questions

Will a WordPress update delete my file?

Core updates do not touch unrecognised files in the root, so an uploaded llms.txt survives. A file placed in a theme directory will not survive a theme update.

Can I edit it from the WordPress admin?

Not by default; the admin has no editor for root files. The dynamic approach above is the usual answer, since it builds the file from content you already edit in the admin.

Does it work on WordPress.com?

On plans that allow plugins or custom code, yes. On lower tiers you cannot write to the root or add PHP, so it is not possible.

Do I need one per site in a multisite network?

Yes. Each domain or subdomain needs its own file, since the convention is per host.
