A Cloudflare Worker that generates llms.txt and llms-full.txt from a Ghost blog. Files are rebuilt on a cron schedule and served from Cloudflare KV.
- A cron job runs hourly and fetches all public posts from Ghost's Content API
- Generates
llms.txt(index grouped by tag) andllms-full.txt(full Markdown content) - Stores both in Cloudflare KV
GET /llms.txtandGET /llms-full.txtserve the files from KV
See DEPLOY.md for the full step-by-step guide.
The short version:
npm install
npx wrangler login
npx wrangler kv namespace create LLMS_KV
npx wrangler kv namespace create LLMS_KV --previewUpdate wrangler.toml with your KV namespace IDs, account_id, and GHOST_URL, then:
npx wrangler secret put GHOST_CONTENT_API_KEY
npm run deployAfter deploying, you can seed the KV store by temporarily setting the cron to * * * * *, deploying, waiting ~60 seconds for it to fire, then restoring 0 * * * * and redeploying. See DEPLOY.md Step 8 for full instructions.
Create a redirects.yaml file and upload it to Ghost Admin → Settings → Labs → Redirects:
302:
/llms.txt: https://ghost-llm.<your-subdomain>.workers.dev/llms.txt
/llms-full.txt: https://ghost-llm.<your-subdomain>.workers.dev/llms-full.txt| Method | Path | Description |
|---|---|---|
GET |
/llms.txt |
Post index grouped by tag |
GET |
/llms-full.txt |
All posts as full Markdown |
Create a .dev.vars file with your Ghost Content API key (this file is gitignored):
GHOST_CONTENT_API_KEY=your_key_here
Start the dev server:
npm run devThen in a second terminal, trigger the scheduled handler to populate local KV:
curl "http://localhost:8787/cdn-cgi/handler/scheduled"Verify the files are populated:
curl "http://localhost:8787/llms.txt"
curl "http://localhost:8787/llms-full.txt"Uses a local KV store — production data is never affected.