LTLLMTXT.co
Gatsby Guide

How to Add llms.txt to a Gatsby Site

Gatsby builds a static site you fully control, so serving a llms.txt at your root is straightforward. Drop it in the static/ folder for a fixed file, or generate it from your GraphQL data in gatsby-node. Both are covered below.

https://

Generate the content first

Both methods deliver the same Markdown, so generate it up front. Our tool reads your live pages and drafts a properly structured llms.txt. Enter your domain, review, and refine.

Generate your file:

https://

Option 1: The static/ folder

Gatsby copies everything in the project-root static/ folder into the build output untouched. Create static/llms.txt with the standard structure:

# Your Site or Company

> One sentence describing what your Gatsby
> site publishes and who it is for.

## Content
- [Blog](https://yourdomain.com/blog): Articles.
- [Guides](https://yourdomain.com/guides): Tutorials.

## Product
- [Features](https://yourdomain.com/features): What it does.
- [Pricing](https://yourdomain.com/pricing): Plans.

## Company
- [About](https://yourdomain.com/about): The story.
- [Contact](https://yourdomain.com/contact): Reach us.

Do not confuse static/ with public/: Gatsby wipes and regenerates public/ on every build, so a file placed there by hand disappears. Always use static/.

Option 2: Generate it in gatsby-node

To build the file from your data, write it in an onPostBuild hook, which runs after the site compiles and can query GraphQL:

// gatsby-node.js
const fs = require("fs");
const path = require("path");

exports.onPostBuild = async ({ graphql }) => {
  const { data } = await graphql(`
    { allMdx { nodes { frontmatter { title slug } } } }
  `);

  const lines = [
    "# Your Site or Company",
    "",
    "> One sentence summary.",
    "",
    "## Blog",
    ...data.allMdx.nodes.map(
      (n) => `- [${n.frontmatter.title}](https://yourdomain.com/${n.frontmatter.slug})`
    ),
  ];

  fs.writeFileSync(
    path.join(__dirname, "public", "llms.txt"),
    lines.join("\n")
  );
};

Because the hook runs after Gatsby has already written public/, writing the file there is safe — it will not be wiped. Every build regenerates the list from current data, so it never goes stale.

Deployment notes

Whichever route you take, the file ends up in public/, which every static host serves from the root. Netlify, Vercel, Cloudflare Pages, and GitHub Pages all work with no rewrites. If your host applies aggressive caching, remember to purge the CDN after you update the file so crawlers get the current version.

Verify it works

1

Open the URL

Visit https://yourdomain.com/llms.txt and confirm you see plain-text Markdown, not an HTML shell.

2

Check the response

curl -I to confirm a 200 served as text/plain. Static hosts infer this from the .txt extension.

3

Validate links

Every URL in the file should return 200 on your deployed site. If you generated the file, verify the slug pattern is correct.

4

Run a visibility check

Use our AI Visibility tool to confirm the file is reachable and parseable from the public internet.

Frequently Asked Questions

Where do static files go in Gatsby?

The static/ folder at your project root. Anything inside it is copied verbatim into public/ during the build and served from your site root, so static/llms.txt becomes yourdomain.com/llms.txt. This is distinct from the public/ folder, which Gatsby regenerates on every build and you should never edit by hand.

When should I generate the file in gatsby-node instead?

When you want the file assembled from your GraphQL data — for example, listing every MDX post or product node — so it stays in sync automatically. An onPostBuild hook writes the file into public/ after the build completes, using the same data your pages are built from.

Does this work on GitHub Pages and other static hosts?

Yes. Gatsby produces a fully static public/ directory, and hosts like Netlify, Vercel, Cloudflare Pages, and GitHub Pages serve it from the root. Both the static-folder and gatsby-node approaches end up as a real file in public/, so there is nothing host-specific to configure.

Do I need a plugin for this?

No. The static folder needs no plugin at all, and the gatsby-node hook uses Node's built-in file system module. A plugin only makes sense if you want a reusable, configurable generator across several sites, which is overkill for a single file.

Is llms.txt guaranteed to influence AI answers?

No. As of mid-2026 llms.txt is a proposed, advisory standard with no enforcement mechanism, and support varies across AI systems. There is no guarantee any model will fetch or use your file. Treat it as a low-cost best practice rather than a guaranteed outcome.

Generate Your llms.txt for Gatsby

Enter your domain and get Markdown to drop into static/ or feed into a gatsby-node generator.

https://