A headless CMS does not render markup. It exposes an API and stores structured data, which means it does nothing for search engines on its own: whatever your frontend builds and serves is what search crawlers index. That is the architectural trade-off teams refer to when they say headless "leaves SEO to the developers".
When engineering teams handle headless SEO poorly (relying on client-side rendering (CSR), neglecting canonical tags, or leaving marketing teams unable to modify meta descriptions without submitting Jira tickets), organic visibility collapses. When implemented correctly, a headless architecture is the most technically resilient setup available for search: full control over raw HTML, sub-second edge response times, deterministic sitemaps, and microdata that cannot drift from user-visible copy.
This guide explains how www.baack.co handles SEO in production. Every code snippet is from our repository, trimmed for length, and every performance metric reflects the live site.
1. Send static HTML, not a client-side loading spinner
Search crawlers can execute client-side JavaScript, but they do not process it synchronously. Google Search Central's rendering documentation describes how Googlebot crawls a page, then queues it for rendering, and runs its JavaScript in a headless Chromium only when resources allow. If your primary headings, copy, pricing tables, or internal links depend on client-side API requests (fetch calls inside useEffect or Vue lifecycle hooks), your pages risk partial indexing, delayed discovery, or complete invisibility during crawl budget constraints.
For content-driven pages, client-side rendering is an architectural misstep. We render every page to static HTML at build time using Astro. Astro reads each page's content entity from the Baack API by path, language, and variant, renders the component tree, and outputs clean HTML.
Reading every page from the API and writing all 506 HTML files takes about 25 seconds on an old laptop, and the files are deployed to Cloudflare Pages. Search engines receive the complete document in the first response:
<!-- The home page's headline as Googlebot receives it: in the HTML, no JavaScript needed -->
<h1 class="mb-4 text-[clamp(40px,6.5vw,68px)] leading-[1.02] font-extrabold tracking-tight [&_em]:block">Content with impact.</h1>
JavaScript is restricted to interactive UI elements: the pricing calculator, interactive demos, and the in-page editor. Anonymous visitors download no client-side framework runtimes to read an article.
This static architecture eliminates Core Web Vitals bottlenecks. When we migrated www.baack.co from its previous stack to static HTML served from Cloudflare's edge, our Lighthouse mobile performance score rose from 30 to 87, Largest Contentful Paint (LCP) dropped from 14.6s to 3.2s, and total transferred payload shrank from 2,449 KB to 163 KB (Lighthouse 12.8, median of three runs, 17 Oct 2026; see the website case study). Google uses Core Web Vitals, including LCP and Interaction to Next Paint (INP), as part of its page experience signals.
2. Treat page titles and descriptions as first-class content
SEO metadata should not be hard-coded into frontend codebases or buried in static JSON dictionaries. Hard-coding metadata creates sprint drag: marketing teams file tickets to tweak a page title, and developers burn sprint capacity on copy changes.
In Baack, meta_title and meta_description are plain text items inside each page's content entity. Marketing leads edit them directly on the live page or in the management console, under the same draft-and-publish workflow, permission controls, and version history as the body text:
---
// src/layouts/BaseLayout.astro
import { placedText, type Placed } from "@/lib/baack/content"
import type { TextItem } from "@/lib/baack/types"
interface Props {
title: string | Placed<TextItem>
description?: string | Placed<TextItem>
canonical?: string
noindex?: boolean
}
const { noindex, canonical } = Astro.props
const title = typeof Astro.props.title === "object" ? placedText(Astro.props.title) : Astro.props.title
const description = typeof Astro.props.description === "object" ? placedText(Astro.props.description) : Astro.props.description
const pageUrl = new URL(Astro.url.pathname.replace(/(index)?\.html$/, ""), Astro.site ?? "https://www.baack.co").href
const canonicalUrl = canonical ?? pageUrl
---
<head>
<meta charset="utf-8" />
<title>{title}</title>
{description && <meta name="description" content={description} />}
{noindex && <meta name="robots" content="noindex, nofollow" />}
{!noindex && <link rel="canonical" href={canonicalUrl} />}
</head>
We keep descriptions between 110 and 155 characters so search results show them in full (a test fails the build for any guide description over 155), while the template appends uniform brand formatting (e.g. {meta_title} | Baack).
3. Canonical URLs and social preview cards
Every indexable page must declare a single source of truth. Without one, as Google's canonicalization guide explains, search engines choose a canonical themselves from the duplicates that query parameters, trailing slashes, or staging environments create, and may not choose the one you want.
In BaseLayout.astro, each page points its <link rel="canonical"> to its absolute production URL on www.baack.co. For syndicated articles originally published on external platforms, editors populate a canonical_url field on the entity to point search engines back to the original source.
The same metadata items populate Open Graph and Twitter Card tags per the Open Graph Protocol:
<!-- Open Graph and Twitter metadata generated from Baack entity items -->
<meta property="og:site_name" content="Baack" />
<meta property="og:type" content={type} />
<meta property="og:title" content={title} />
{description && <meta property="og:description" content={description} />}
<meta property="og:url" content={canonicalUrl} />
<meta property="og:locale" content={ogLocale(lang)} />
{image && <meta property="og:image" content={image.src} />}
{image && <meta property="og:image:alt" content={image.alt} />}
<meta name="twitter:card" content={image ? "summary_large_image" : "summary"} />
One practical detail regarding social banners: page banners designed for widescreen layouts (such as our 1200 by 480 hero assets) are aggressively cropped when shared on LinkedIn, X, or Slack. Social platforms standardize on a 1.91:1 ratio. Pages that get shared have their own share_image item, which we make 1200 by 630 pixels, giving marketing autonomy over social cards without distorting in-page design.
4. Internationalization and hreflang tags
Serving multi-region or multilingual markets requires explicit relationship mapping. Without valid alternate language tags, search engines struggle to index the correct regional URL, resulting in US pricing appearing to UK visitors or regional duplication issues.
Each Baack entity has a BCP 47 language (such as en-GB, en-US or en-IE) and a variant. When the site reads a page, the Baack API returns alternativeLanguages, listing every language that page exists in. At build time, the template maps this array directly into <link rel="alternate" hreflang="..."> tags, following Google's guide to localized versions:
<html lang="en-GB">
<link rel="canonical" href="https://www.baack.co/en-GB/pricing">
<link rel="alternate" hreflang="en-US" href="https://www.baack.co/en-US/pricing">
<link rel="alternate" hreflang="en-GB" href="https://www.baack.co/en-GB/pricing">
<link rel="alternate" hreflang="en-IE" href="https://www.baack.co/en-IE/pricing">
<link rel="alternate" hreflang="x-default" href="https://www.baack.co/en-US/pricing">
Each localized version exists as an independent entity with region-specific currencies and localized copy, remaining canonical to itself. The x-default directive specifies the fallback URL for unmatched locales. Because these alternate relationships are managed at the CMS entity layer, adding a locale updates the hreflang links across the site at the next build, without template changes.
5. Inline microdata over disconnected JSON-LD
Most headless implementations output structured data by generating a disconnected <script type="application/ld+json"> block. While supported by search engines, separated JSON-LD blocks frequently cause data drift: a developer updates an editorial component, but the JSON-LD serialization logic is overlooked, and the structured data contradicts the page copy. Google's structured data guidelines require it to describe the content visitors see, and a page whose markup doesn't can lose its rich results.
Where content is rendered directly by UI components, www.baack.co writes schema.org markup as W3C Microdata directly on the rendered HTML elements. The microdata attributes live on the same tags displaying the content:
---
// src/components/content/BlogPostArticle.astro (simplified)
const { post, canonicalUrl, headingClass } = Astro.props
---
<article itemscope itemtype="https://schema.org/BlogPosting" class="mx-auto max-w-3xl">
<link itemprop="url" href={canonicalUrl} />
<meta itemprop="inLanguage" content={post.language} />
<h1 itemprop="headline" class={headingClass}>
{post.title}
</h1>
<div class="mt-4 flex items-center gap-3">
<div itemprop="author" itemscope itemtype="https://schema.org/Person">
<a itemprop="url" href={`/people/${post.author.slug}`} class="font-semibold text-foreground">
<span itemprop="name">{post.author.name}</span>
</a>
</div>
<meta itemprop="datePublished" content={post.publishedAt.toISOString()} />
{updated && (
<time itemprop="dateModified" datetime={updated.toISOString()}>
Updated {dateFormat.format(updated)}
</time>
)}
</div>
<div itemprop="articleBody" class="prose mt-8">
<slot />
</div>
</article>
Because the microdata attributes are bound to the presentation components, schema attributes and visible text are identical by definition.
For compound catalog entities and global properties, we complement microdata with JSON-LD (src/lib/structured-data.ts). Across www.baack.co, our production schema footprint covers:
| Content Type | Schema.org Specification | Implementation Method |
|---|---|---|
| Blog posts | BlogPosting, Person |
HTML Microdata in the article layout |
| Docs and guides | TechArticle, APIReference |
JSON-LD in the docs layout |
| Step-by-Step Tutorials | HowTo, HowToStep |
HTML Microdata on step components |
| Navigation Hierarchy | BreadcrumbList |
Microdata on breadcrumb navigation |
| Software Pricing | SoftwareApplication, Offer |
JSON-LD on the pricing pages |
| Plan prices | Product, Offer, UnitPriceSpecification |
HTML Microdata on the plan cards |
| Publisher Identity | WebSite, Organization |
JSON-LD graph on root landing pages |
6. Build-derived sitemaps that eliminate index drift
In headless setups, sitemaps are often maintained manually or queried dynamically from CMS APIs. Both methods introduce operational failure modes:
- API query drift: CMS APIs may report unpublished drafts, staging routes, or entities lacking frontend routes, generating soft 404 errors in Google Search Console.
- Hard-coded lists: Developers forget to add new landing pages, leaving them orphaned.
We resolve this by generating sitemap.xml strictly after the build, parsing the compiled HTML files inside dist/. If a page was not compiled into a valid HTML file, it cannot appear in the sitemap.
Our build script (scripts/sitemap.ts) inspects the compiled distribution output, filtering out redirects, pages that opt out, and pages explicitly carrying a noindex tag:
import { readdir, readFile, writeFile } from "node:fs/promises"
import { SITE_URL } from "../src/lib/site.ts"
import { isListed, pagePath, sitemapXml } from "../src/lib/sitemap.ts"
const dist = new URL("../dist/", import.meta.url)
const files = (await readdir(dist, { recursive: true })).filter((file) => file.endsWith(".html"))
const paths: string[] = []
for (const file of files) {
if (isListed(await readFile(new URL(file, dist), "utf8"))) paths.push(pagePath(file))
}
await writeFile(new URL("sitemap.xml", dist), sitemapXml(SITE_URL, paths))
The filter helper (src/lib/sitemap.ts) evaluates robots metadata and redirect patterns directly from the rendered HTML:
export function isListed(html: string): boolean {
const headEnd = html.search(/<\/head>/i)
// Redirect pages have no <head> element; read the whole page.
const head = headEnd === -1 ? html : html.slice(0, headEnd)
const robots = /<meta\s+name=["']robots["']\s+content=["']([^"']*)["']/i.exec(head)?.[1] ?? ""
if (/\bnoindex\b/i.test(robots)) return false
if (/<html\b[^>]*\sdata-sitemap=["']exclude["']/i.test(head)) return false
return !/<meta\s+http-equiv=["']refresh["']/i.test(head)
}
Out of 506 compiled files in our production build, exactly 122 pages are written to sitemap.xml. The remaining 384 files are 379 redirect pages for old URLs and the noindex pages: search, 404, the account pages and the console. Crawlers never encounter dead routes or redirect loops within our sitemap.
7. Preserve link equity across migrations
Migrating from a legacy monolithic CMS (e.g. WordPress, Drupal) to a headless architecture is where companies forfeit organic rankings. When URL hierarchies change without meticulous redirect mappings, incoming backlinks return 404 errors, erasing accumulated domain authority.
During our platform migration, 378 legacy documentation paths were mapped to new URL structures. Rather than relying on heavy server-side redirect databases or expensive CDN edge compute routes, each legacy URL was compiled as a static redirect page with an instant meta refresh and a canonical link to its new address. Renames since then are 301s in Cloudflare's _redirects file:
# public/_redirects (Cloudflare Pages)
/pricing /en-US/pricing 301
/blog/content-modelling-best-practices-guide /blog/content-modeling-best-practices-guide 301
Google's redirects guide treats both a 301 and an instant meta refresh as a permanent redirect: a strong signal that the new address should be the canonical one.
8. Communicate freshness with Last-Modified headers
Static site generators compile HTML to disk. If your server sends the deployment time as the HTTP Last-Modified header, every page appears modified whenever any typo is fixed or a page is added, and crawlers can't tell which pages actually changed.
As documented in Google's Crawl Budget Management guide, search engines leverage HTTP conditional requests (If-Modified-Since and If-None-Match) to bypass unchanged content.
We solve this by decoupling the build timestamp from the content publish timestamp. A post-build script (scripts/page-meta.ts) extracts the <html data-entity-urn="..."> from each compiled page, queries the Baack API for the entity's real publishTimestamp, and writes dist/_page-meta.json.
At the edge, a Cloudflare Pages Function (functions/_middleware.ts) reads that file and sends each page's content timestamp:
// functions/_middleware.ts (Cloudflare Pages Functions, trimmed)
import { pageKey, PAGE_META_FILE, type PageMetaManifest } from "../src/lib/page-meta.ts"
export async function onRequest(context: Context): Promise<Response> {
const { request } = context
const response = await context.next()
if (request.method !== "GET" && request.method !== "HEAD") return response
if (response.status !== 200 || !response.headers.get("content-type")?.includes("text/html")) return response
const meta = (await readManifest(context))[pageKey(new URL(request.url).pathname)]
if (!meta) return response
const headers = new Headers(response.headers)
if (meta.lastModified) headers.set("Last-Modified", meta.lastModified)
return new Response(response.body, { status: response.status, statusText: response.statusText, headers })
}
Rebuilding the site doesn't change a page's Last-Modified; publishing its content does. A page whose content hasn't changed in a month says so, however many deploys have happened since.
The function also sets an ETag, but Cloudflare strips it before the response leaves its network, so Last-Modified is the freshness signal crawlers get. It is a signal, not a saving: the site still sends the full page every time. To save the transfer as well, the same function could answer an If-Modified-Since request with 304 Not Modified when the time matches.
Static pages are only as fresh as the last build, so the build should follow publishing. On www.damienallison.com, another static Astro site built on Baack, publishing sends a Baack webhook that starts a new build. The build takes 33 to 47 seconds and the deploy about 20, so a publish is live about 2 minutes later. This site still rebuilds by hand after publishing, and is moving to the same webhook.
9. Real-world scoring nuances: Lighthouse vs indexing realities
Synthetic audit tools like Google Lighthouse provide useful development benchmarks, but high scores do not guarantee indexation. Two specific configuration choices on www.baack.co illustrate why real-world search behavior differs from tool scores:
- SEO Score 92 vs 100: Cloudflare's managed
robots.txtpolicy injects aContent-Signaldirective to restrict unauthorized AI training scrapers. Lighthouse flags this directive as an unknown token and fails its robots.txt audit. Googlebot ignores directives it does not recognize; search indexing is completely unaffected. - Best Practices Score 93 vs 100: Cloudflare's edge bot management inserts an automated verification script. Our strict Content Security Policy (CSP) restricts unvetted scripts, causing Lighthouse to register an execution error. Local production builds without CDN proxying score 100.
Beyond synthetic metrics, search engines evaluate content novelty. Search algorithms filter out commodity copy that restates well-trodden definitions. Publishing verified production code, actual performance figures, and original architectural benchmarks establishes the topical authority search engines prioritize when allocating organic reach.
Summary
Operating a headless CMS that ranks reliably requires aligning frontend engineering with content operations:
- Render static HTML at the edge: Eliminate client-side data fetching for indexable content, and keep JavaScript for interaction.
- Give marketing direct in-page metadata control: Store page titles, meta descriptions, and 1.91:1 share images directly inside content entities so copy can be updated without code changes.
- Enforce canonical and hreflang parity: Declare absolute canonical URLs and map multi-region entity variants directly to alternate tags.
- Bind structured data to the DOM: Use W3C Microdata on layout components to make schema drift structurally impossible.
- Derive sitemaps from build artifacts: Parse compiled HTML to guarantee every sitemap URL resolves with a 200 OK.
- Send the content's age, not the deploy's: Set
Last-Modifiedfrom when the content was published, so rebuilds don't make every page look new.