Skip to content

Instant publishing

Content goes live on every commit, without a rebuild. When an editor publishes, Alinea commits the change to your repository and your site starts serving it right away.

How it works

Every publish in the dashboard is a git commit. After the commit, the site syncs the new content sha from its own handler, so the next request that renders content reads the latest version. No build or redeploy has to finish before editors see their changes on the live site.

DashboardYour site's handlerGit repositoryYour running siteCI buildEditor clicks Publish/api/cmscontent/**/*.jsonServes the new contentSkipped when a commit onlytouches contentpublishcommitrevalidatepush
1Publishing writes a commit to your repository through your own handler.2The handler marks your pages stale, and they rebuild in the background with the new content.3An ignoreCommand skips the CI build when only content changed.

Skip builds for content-only commits

Only set this up once your deployed site has a backend that syncs content at runtime: Alinea Cloud or a self-hosted backend. Without one, a deployment is how new content reaches your site, so skipping content-only builds would leave published changes offline.

Because content is synced at runtime, a publish from the dashboard does not need a new deployment. Every commit the dashboard makes ends with an Alinea-Content trailer, holding the hash of the content it commits. On Vercel you can skip the builds of those commits with an ignoreCommand in vercel.json. The command exits successfully, which tells Vercel to skip the build, when the latest commit is a publish from the dashboard and changed nothing outside the content directory:

vercel.json
{
  "ignoreCommand": "git log -1 --format=%B | grep -q '^Alinea-Content:' && git diff --quiet HEAD^ HEAD -- . ':!content'"
}

Everything else builds as before: commits you push yourself never carry the trailer, so a merge that pulled in published content, or a push of code with a content commit on top, still deploys your code. A publish that uploads a file to a media directory outside content builds too.

Check that it works

A skipped build shows as Canceled in the deployments of your Vercel project, and the list hides canceled deployments by default. Filter on Status → Canceled to find them: their log ends with "Ignored Build Step command returned exit code 0". To check the whole setup:

  1. Publish a change in the dashboard.

  2. Find the deployment of its commit: it shows as Canceled.

  3. Load the page: it shows the change without a redeploy.

This checks both halves of the setup: content-only commits skip their build, and the site syncs their content at runtime.

Static pages

Static pages are revalidated for you. Every page that queries content is tagged, and after each commit the handler marks those pages as stale. The next visit is still answered from the cache while Next.js rebuilds the page in the background, and the visit after that gets the new content. No visitor waits for a render, and no revalidatePath call is needed. This includes pages generated with generateStaticParams: revalidation code in afterCommit that refreshes them by hand, such as revalidateTag('_N_T_/layout') or revalidatePath('/', 'layout'), can be removed.

Pages rendered at request time sync on their next render. The first one after a commit can still show the previous version while the shared content sha refreshes. Content pushed to your repository without the dashboard, for example a local edit, skips the handler: pages pick it up within five minutes, or within syncInterval seconds when your config sets it. Use the handler's afterCommit hook if other caches in your app depend on content, for example your own fetch tags. It receives the changed entries and the removed ones, see [Commit hooks](page:guides/deploy#commit-hooks):

app/(alinea)/api/cms/route.ts
import {cms} from '@/cms'
import {createHandler} from 'alinea/next'
import {revalidateTag} from 'next/cache'

const handler = createHandler({
  cms,
  afterCommit({entries, removed}) {
    const changed = [...entries, ...removed]
    if (changed.some(entry => entry.type === 'Product'))
      revalidateTag('products', 'max')
  }
})

export const GET = handler
export const POST = handler