Skip to content

goslingo/ghost-llm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ghost-llm

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.

How it works

  1. A cron job runs hourly and fetches all public posts from Ghost's Content API
  2. Generates llms.txt (index grouped by tag) and llms-full.txt (full Markdown content)
  3. Stores both in Cloudflare KV
  4. GET /llms.txt and GET /llms-full.txt serve the files from KV

Setup

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 --preview

Update wrangler.toml with your KV namespace IDs, account_id, and GHOST_URL, then:

npx wrangler secret put GHOST_CONTENT_API_KEY
npm run deploy

After 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

Endpoints

Method Path Description
GET /llms.txt Post index grouped by tag
GET /llms-full.txt All posts as full Markdown

Local development

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 dev

Then 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors