Headless WordPress: the complete guide
What headless WordPress is, when it’s worth it, how the front end gets the content, and how to solve the parts most guides skip: preview, editing, publishing and SEO.
Headless WordPress means keeping WordPress for writing and managing content, and building the public website with something else: Next.js, Astro, Nuxt, SvelteKit or plain HTML. WordPress becomes the back office. The front end becomes a separate project that reads the content and displays it.
I build client sites this way, and I wrote this guide to cover the whole picture: when it’s a good idea, when it isn’t, how the pieces connect, and the problems you only discover after launch.
What headless WordPress is
A classic WordPress site does two jobs at once. It stores the content, and its theme turns that content into the pages visitors see. Headless splits those jobs:
- WordPress keeps the admin, the users, the media library and the content. Editors log in to wp-admin as usual.
- The front end is a separate application. It fetches the content from WordPress through an API, then renders the pages with its own code and design.
- The theme no longer matters. Visitors never see a page generated by WordPress.
You’ll also see the word “decoupled”. In practice people use the two words for the same thing.
Why teams go headless
- Speed. A front end built with Astro or Next.js can be served as static files from a CDN. No PHP and no database query on each visit.
- Freedom on the front end. Developers work with the framework, components and tools they already use, instead of a theme and a page builder.
- Security. WordPress is no longer the public site. It can live on a subdomain nobody visits, with very few plugins, behind access rules. I wrote a whole article on this: Keep WordPress, change the front end.
- Editors keep what they know. Compared with moving to Sanity, Contentful or Strapi, the team keeps the WordPress admin, the content and the users they already have.
- One source, several outputs. The same content can feed a website, an app or a second site.
When headless is not worth it
Headless adds a second project to build, host and maintain. It’s the wrong choice when:
- There is no developer. Someone has to write and maintain the front end. A site run entirely by a marketing team with a page builder is better off staying classic.
- The site depends on plugins that print things on the page. Sliders, form builders, booking widgets, membership areas: on a headless site, everything the theme or a plugin used to display must be rebuilt on the front end. Data plugins keep working; display plugins don’t.
- The editors build layouts themselves. If they assemble pages block by block every week, a headless front end with fixed templates will feel restrictive, unless you plan for it (see the section on content modelling).
- The budget is tight and the site is small. A five-page brochure site on good hosting with a cache is already fast.
How the front end gets the content
There are three common ways to read WordPress content from a front end.
1. The REST API (built in)
Every WordPress site has a REST API at /wp-json/. Posts, pages, media, categories and custom post types (registered with show_in_rest) are available without installing anything.
// An Astro page: list the latest posts at build time
---
const res = await fetch('https://cms.example.com/wp-json/wp/v2/posts?per_page=10&_embed');
const posts = await res.json();
---
<ul>
{posts.map((post) => (
<li><a href={`/blog/${post.slug}`} set:html={post.title.rendered} /></li>
))}
</ul>
ACF fields appear in the REST API once you turn on “Show in REST API” in the field group settings. The REST API is the simplest option, and every plugin with a REST endpoint works with it. Its drawback: one request per type of content, sometimes per page, and responses carry a lot you don’t need.
2. GraphQL with WPGraphQL
WPGraphQL is a free plugin that adds a GraphQL endpoint. You ask for exactly the fields you need, across types, in one query. Add WPGraphQL for ACF to expose your custom fields.
query LatestPosts {
posts(first: 10) {
nodes { title slug date excerpt }
}
}
It’s popular with Next.js teams and well documented. The cost: one more plugin, and an add-on for each plugin whose data you want in the schema (ACF, Yoast and others).
3. A content API made for a front end
Some plugins serve the content already shaped for a front end. Leiho’s content API, for example, returns every published item of the site in one request, with images, relations and ACF fields ready to use and TypeScript types generated from your field groups. A static build then makes one call instead of hundreds, which also spares shared hosting.
All three can live together. Nothing stops you from keeping WPGraphQL for one part of the site and reading the rest another way.
Choosing the front end
- Astro is a strong fit for content sites: it ships HTML by default and only adds JavaScript where you ask for it. See Leiho for Astro.
- Next.js suits sites that mix content with application features (accounts, dashboards, search). See Leiho for Next.js.
- Nuxt and SvelteKit are the same idea for Vue and Svelte teams.
- Plain HTML, Eleventy or Hugo work too: they just read JSON at build time.
The more important choice is how pages are rendered:
- Static: pages are built once and served as files. Fastest and safest, but the site must be rebuilt when content changes.
- Server rendering: pages are built on each request (or cached for a while). Content is always fresh, but there is a server to run and secure again.
- Mixed: static pages refreshed on demand (Next.js revalidation, for example). A good middle ground for large sites.
Modelling the content
On a headless site, structured fields work much better than one big block of HTML. A hero title, an image and a button are three fields your components can place exactly where the design wants them.
- ACF, ACF PRO or Secure Custom Fields are the usual choice: field groups on pages and custom post types, repeaters and flexible content for sections editors can add and reorder.
- JetEngine covers the same need with its own meta boxes and custom content types.
- Gutenberg blocks can work headless, but the API gives you rendered HTML by default. Either you style that HTML on the front end, or you parse the blocks and map each one to a component, which takes more work.
A simple rule: fixed layouts with fields for pages that matter (home, services, landing pages), rich text for articles.
The hard part: preview and editing
This is where most headless projects disappoint editors, and most guides stop short.
In a classic WordPress site, the Preview button shows the page as it will look. On a headless site, that button opens the WordPress theme, which nobody uses. Editors fill in forms in wp-admin, save, wait for a build, and only then see what they did on the real site.
The usual fixes:
- A custom preview route. Point the preview link (with the
preview_post_linkfilter) to a route on the front end that receives the post ID and a short-lived token, then fetches the draft. Next.js Draft Mode is built for this. It works, but it’s yours to build and maintain, and editors still edit in forms. - A framework that handles it. Faust.js, from WP Engine, provides previews and authentication for Next.js sites built on WPGraphQL.
- Visual editing on the real front end. This is what I built Leiho for. It opens your actual front end inside wp-admin. Editors click a heading, an image or a button on the page, change it in a panel, and see the page update as they type. It writes to the fields you already have (ACF, SCF, JetEngine or its own Collections), and the design stays in your code.
Whatever you choose, test it with the real editors before launch. A headless site they find hard to update will end up in your inbox as “can you change this sentence for us?”.
Publishing changes
With a static front end, saving in WordPress doesn’t change the live site by itself. Something has to rebuild it:
- A build hook. Vercel, Netlify and Cloudflare Pages give you a URL that starts a new build. WordPress calls it after a change.
- A CI workflow. GitHub Actions builds and deploys; WordPress dispatches the workflow.
- On-demand revalidation. With server rendering, WordPress tells the front end which pages to refresh.
Watch out for three things: rebuilding on every keystroke (batch the changes), scheduled posts (WP-Cron only runs when someone loads WordPress, which rarely happens on a headless site, so set up a real cron job), and telling editors when their change is actually live. Leiho’s Publish button handles these: it calls your build hook, GitHub Actions or Coolify, follows the deployment until it’s done, and can publish on its own once edits stop.
SEO on a headless WordPress site
Search engines only see the front end, so the front end is responsible for everything SEO plugins used to print in the theme.
- Meta tags. Title, description, canonical and Open Graph must be written by your front end. If you use Yoast, its data is in the REST API (
yoast_head_json); Rank Math has a similar endpoint. - Sitemap and robots.txt come from the front end, with the front end’s URLs.
- Redirects. When an editor changes a slug in WordPress, the old URL must redirect on the front end. Plan for it from day one.
- Hide WordPress itself. The CMS subdomain should be
noindex, or you’ll have two copies of every page in Google. - Structured data. JSON-LD (Article, Product, FAQ…) is easiest to produce from structured fields.
- AI search. Assistants like ChatGPT and Claude read pages too. An
llms.txtfile and a Markdown version of your pages make the site easier for them to quote.
Done well, headless is good for SEO: fast pages, clean HTML and full control over every tag. Leiho can produce structured data, llms.txt and Markdown pages from your fields.
Security and hosting
- Put WordPress on its own subdomain (for example
cms.example.com) and keep the front end on the main domain. - Keep plugins to the minimum: on a headless site, most display plugins have no reason to be there.
- Close what the front end doesn’t need: XML-RPC, the public user list, the theme’s pages. Leiho does this when you turn on WordPress as a back office.
- Protect the hosting account and DNS of the front end with two-factor authentication: on a static site, that’s where the keys are.
For hosting, WordPress can stay on the PHP host it already has. The front end goes to Vercel, Netlify, Cloudflare Pages or your own server. Budget for two things to run instead of one.
A minimal setup, step by step
- Move WordPress to a subdomain, or install a fresh one there.
- Model the content with ACF, SCF, JetEngine or Leiho Collections, and turn on REST access for those fields.
- Create the front end (Astro or Next.js) and fetch the content at build time.
- Write the meta tags, sitemap and redirects on the front end.
- Set
noindexon the WordPress subdomain and redirect its public pages to the front end. - Connect a build hook so that publishing in WordPress rebuilds the site.
- Give editors a preview or visual editing they’re comfortable with, and test it with them.
- Set up a real cron job for scheduled posts.
The Leiho quick start covers steps 2, 6 and 7 for any framework, and you can try the editor in your browser on a demo site, with nothing to install.
Frequently asked questions
Is headless WordPress worth it?
Yes, when you have a developer, a site that matters for performance or design, and editors who already know WordPress. No, for a small site run without a developer.
Do WordPress plugins still work on a headless site?
Plugins that manage data (custom fields, users, translations, SEO data) keep working and expose their data through the API. Plugins that display things on the page (sliders, forms, page builders) don’t: the front end has to rebuild those.
Can I use Gutenberg with headless WordPress?
Yes. You get the rendered HTML of each post through the API and style it on the front end. To turn each block into your own component, you need to parse the blocks, which is more work.
Can WooCommerce run headless?
Yes, through the WooCommerce Store API for the catalogue, cart and checkout. It’s a much larger project than a content site: payments, accounts and taxes all have to be handled on the front end.
REST API or WPGraphQL?
Start with the REST API if your needs are simple or your plugins only offer REST. Choose WPGraphQL if your team likes GraphQL and you need precise queries across types. Both are free.
Is headless WordPress good for SEO?
It can be better than classic WordPress, because pages are fast and you control every tag. But the front end must handle meta tags, sitemap, redirects and structured data itself, and the CMS must not be indexed.