A food/recipe site scaffold: Astro 5 with the @astrojs/cloudflare adapter in output: 'server'
mode, content-collection-driven recipes, schema.org Recipe JSON-LD, and Wrangler wired for
Cloudflare Pages deploys.
./dev.sh # installs deps if needed, then starts http://localhost:4321Or manually:
npm install npm run dev
| Command | What it does |
|---|---|
npm run dev |
Astro dev server on http://localhost:4321 (--host so phones on your LAN can hit it). Cloudflare vars/bindings are proxied in via platformProxy. |
npm run build |
Builds to dist/ (dist/_worker.js + static assets). |
npm run preview |
Runs the built output in the real workerd runtime: wrangler pages dev ./dist. |
npm run deploy |
Build + wrangler pages deploy ./dist. |
npm run check |
Type-checks .astro/.ts files. |
npm run cf-typegen |
Regenerates binding types from wrangler.toml. |
food-site/
├── astro.config.mjs # SSR + Cloudflare adapter (platformProxy on)
├── wrangler.toml # Pages config, vars, commented KV/D1/R2 bindings
├── dev.sh # one-command local start
├── .dev.vars.example # local secrets template (copy to .dev.vars)
├── public/
│ ├── favicon.svg
│ ├── robots.txt
│ └── _headers # cache + security headers served by Cloudflare
└── src/
├── consts.ts # site title, nav, categories
├── content.config.ts # `recipes` collection + Zod schema
├── content/recipes/*.md # your recipes live here
├── layouts/BaseLayout.astro # html shell, SEO/OG meta, JSON-LD slot
├── components/ # Header, Footer, RecipeCard
├── lib/recipes.ts # query helpers + schema.org builder
└── pages/
├── index.astro
├── about.astro
├── 404.astro
├── sitemap.xml.ts
├── api/subscribe.ts # example SSR endpoint using bindings
└── recipes/
├── index.astro # /recipes
├── [slug].astro # /recipes/paprikas-krumpli
└── category/[category].astro # /recipes/category/baking
Create src/content/recipes/my-recipe.md. The filename becomes the URL slug.
Frontmatter is validated by Zod at build time, so a typo fails loudly instead of shipping.
--- title: "Roast Chicken" description: "One bird, one tray, forty minutes." publishDate: 2026-07-25 category: mains # breakfast | mains | baking | sides | desserts | drinks tags: ["sunday", "one-tray"] prepMinutes: 10 cookMinutes: 45 servings: 4 difficulty: easy draft: false # drafts show in dev, hidden in production ingredients: ["1 whole chicken", "..."] steps: ["Heat the oven to 220°C.", "..."] --- Markdown body renders under the method — notes, swaps, storage tips.
npx wrangler login
npm run deploy # first run creates the Pages project interactivelyThe repo is connected to Cloudflare's Git integration: every push to main triggers a
build on Cloudflare's side and deploys to production at
pertutti.pages.dev. Other branches get preview deployments.
No secrets or tokens live in GitHub.
.github/workflows/ci.yml runs alongside it as a check only — install, astro check,
astro build. It never deploys, so there's no double-deploy race. Its job is to fail a PR
when a recipe has bad frontmatter or the build breaks, before Cloudflare ships it.
Budget notes: the Cloudflare free plan allows
500 builds/month, 1 at a time;
Actions minutes are free on public repos. Add [CI Skip] to a commit message to make
Cloudflare skip a build for docs-only changes.
If you ever want deploys to run from Actions instead, turn off automatic deployments in the
Pages project, then add CLOUDFLARE_API_TOKEN (Account → Cloudflare Pages → Edit) and
CLOUDFLARE_ACCOUNT_ID as repo secrets and restore a deploy step using
cloudflare/wrangler-action@v3.
Secrets: npx wrangler pages secret put NEWSLETTER_API_KEY.
Bindings (KV/D1/R2): uncomment the blocks in wrangler.toml, create the resource with
Wrangler, then read them in any page or endpoint via Astro.locals.runtime.env.<BINDING>.
- Every route is server-rendered by default. To prerender a page at build time, add
export const prerender = true;in its frontmatter — good candidates are/aboutand/404. recipeJsonLd()insrc/lib/recipes.tsemits schema.org Recipe markup, which is what gets recipe cards and cook-time chips into Google results.- Update
siteinastro.config.mjsto your real domain so canonical URLs and the sitemap are correct.
Two optional frontmatter fields power the language side of the site:
titleNl: "Hongaarse paprika-aardappelen" # shown under the title, in blue script glossary: - nl: "sudderen" en: "to simmer" say: "SUH-deh-ren" # optional phonetic hint note: "Laat het twintig minuten sudderen." # optional usage note
glossary renders as a panel under the ingredients on the recipe page, and every
term is collected automatically into /glossary (Woordenboek), merged by word,
sorted with Dutch collation, and linked back to the recipes it came from. Both
fields are optional — recipes without them look exactly as before. Glossary words
are also added to the recipe's JSON-LD keywords, and titleNl becomes its
alternateName.