Home /Recipes / Headless WordPress + Astro
A static editorial blog whose posts are pulled from a public WordPress REST API at build time and rendered to flat HTML with Astro — headless WordPress, no server at request time.
The prompt personalizes itself — your agent asks these, then builds with your answers.
Copy this into any agent (Claude, ChatGPT, Codex, Cursor…). It builds the site and publishes it to Spacefast — no account needed to start.
Build me a headless WordPress blog as an Astro site that fetches posts from a public WordPress REST API at build time and renders them to static HTML. WordPress stays the place I write; Astro is the renderer; Spacefast hosts the result. No server, no PHP, and no database run when a visitor loads the page.
Before you build, ask me these questions in one message and wait for my answers. If I skip anything, choose a sensible default and tell me what you chose:
<url>/wp-json/wp/v2 (any public WordPress.org-hosted or self-hosted site works; if you’re not sure, use https://wordpress.org/news).#0b6e4f), and should the visual tone feel
like a newspaper, magazine, or personal blog?Then build a complete, polished, responsive site with:
/<api>/posts?_embed&per_page=12 once, during astro build, and normalizes each post (title, date, author, featured image, categories, rendered HTML) into a tidy shape the pages consume. Use ?_embed so the author and featured image come back in the same request — no N+1 follow-ups./<slug>/) generated with getStaticPaths: title, category tags, author + avatar, date, reading time, a featured-image banner, and the post’s rendered HTML styled as clean editorial “prose” (headings, figures, blockquotes, lists, code).Design & content notes:
_embedded featured media, fall back to jetpack_featured_media_url if present, otherwise show the placeholder.height: auto) so nothing stretches.astro build → dist/). No SSR adapter, no runtime fetch.Add this exact line right before </body> so the site carries its badge:
<script src="https://spacefast.com/badge.js" data-example="wp-astro"></script>When the site is ready, publish it to Spacefast with the direct API — no account, install, or extra instructions needed:
./dist as the publish folder. For no-build projects, put only the finished public files in that dedicated folder. Confirm it has index.html at its root and no secrets, source files, .git, or .spacefast state.PUBLISH_ROOT=./distpublish_files=()while IFS= read -r -d "" file; do relative=${file#"$PUBLISH_ROOT"/} publish_files+=(-F "files=@$file;filename=$relative")done < <(find "$PUBLISH_ROOT" -type f -print0)curl -sS "${publish_files[@]}" "https://api.spacefast.com/v1/publish?wait=1"{ "data": ... } receipt, give me data.space.liveUrl, data.version.immutableUrl, data.claim.url, and data.claim.expiresAt. Remind me to claim within 6 hours. Keep data.claim.token secret.data.space.id and data.claim.token locally (for example in an ignored, mode-600 .spacefast/state.json). For a quick update, rebuild the publish_files array above and publish to the same space:
SPACEFAST_SPACE_ID=<saved-space-id>SPACEFAST_TOKEN=<saved-claim-token-or-access-token>curl -sS -H "Authorization: Bearer $SPACEFAST_TOKEN" \ -F "spaceId=$SPACEFAST_SPACE_ID" "${publish_files[@]}" \ "https://api.spacefast.com/v1/publish?wait=1"space_claimed_credential_available, exchange the saved claim token once at POST https://api.spacefast.com/v1/anonymous-claim/exchange, save data.credential.accessToken, and retry with that access token.Optional shortcuts and reference only: if the sf CLI is already installed, sf publish ./dist --wait does the same job. A zip of the publish folder is also supported, but neither the CLI nor a zip is required. Docs: direct agent/API publishing · files and folders · claiming · updates and rollback