DEV Community

Andriy Pyvovarchuk
Andriy Pyvovarchuk

Posted on Originally published at llms-txt-validator.dev

How to add llms.txt to WordPress (3 ways, pick the one that fits)

WordPress powers something like 40% of the web, so "how do I add an llms.txt to WordPress?" is a question a lot of people are about to ask. Good news: the file just has to be served at https://yoursite.com/llms.txt as plain text — and there are three ways to get there depending on how much access you have.

(New to the format? It's a small Markdown file that tells AI models what your site is and which pages matter — start with a quick primer, then come back.)

Option 1 — Upload the file (simplest, no plugin)

If you can reach your files (host file manager or SFTP), this is the cleanest path:

  1. Write your llms.txt (one # title, a > summary, ## sections of links).
  2. Upload it to the web root — usually public_html/ — so it lands at yoursite.com/llms.txt.

Done. No plugin, nothing to maintain. This is the right answer for most self- or managed-hosted WordPress sites.

Option 2 — Serve it with a snippet (no file access)

Can't upload files? Add a tiny route. Drop this in your theme's functions.php (or a code-snippets plugin):

add_action('init', function () {
  if (trim($_SERVER['REQUEST_URI'], '/') === 'llms.txt') {
    header('Content-Type: text/plain; charset=utf-8');
    echo "# Example\n\n";
    echo "> Example is a WordPress site about X. These links cover the essentials.\n\n";
    echo "## Guides\n- [Start here](https://example.com/start): The 5-minute intro\n";
    exit;
  }
});
Enter fullscreen mode Exit fullscreen mode

It intercepts the request for /llms.txt and returns plain text directly — no file on disk needed.

Option 3 — Use a plugin

Several SEO/AI plugins now generate an llms.txt from your pages automatically. Handy if you don't want to touch code — but review the output. Auto-generators love to dump every page and wrap in marketing copy; llms.txt is a curated index, so trim it to the pages that actually matter.

The WordPress-specific gotchas

These trip people up more than the file itself:

  • Purge your cache/CDN after publishing — WordPress caching plugins and CDNs will happily serve a stale 404 for /llms.txt until you clear them.
  • Root, not a subfolder — it must be yoursite.com/llms.txt, not yoursite.com/blog/llms.txt.
  • Plain text, not HTML — make sure it's served as text/plain, not rendered through a page template as text/html.

Verify it actually works

The failure you won't see on your own: it loads for you but returns a cached 404 to everyone else, or the linked pages 404. Run your domain through an llms.txt validator — it confirms the file is served correctly as plain text and that every linked page actually loads. Aim for 100/100, then you're done.

Pick the option that matches your access, mind the cache, validate, ship. Ten minutes on the world's most common CMS.

Top comments (0)