Rebuild a static site when you publish in your CMS
By the SharpWrite team · Published
Short answer
A static site only shows new content after it is rebuilt. Create a deploy hook (a plain URL) at your host, paste it into your CMS as a webhook, and the CMS calls it every time you publish, change, unpublish or delete an entry. The setup takes a few minutes. The common failures are a cached API response, a wrong URL and a host that ignores the call.
In this post
You publish a post in your CMS, open your site and see nothing new. That is normal for a static site. The pages were built before the post existed, and they stay as they are until something rebuilds them.
The fix is a webhook: when you publish, the CMS sends a message to your host, and the host rebuilds the site. Here is how to wire that up, with SharpWrite as the example CMS. The same steps work with any CMS that can call a URL.
Why a static site does not update on its own
A static site generator such as Astro, Eleventy or Next.js in static mode fetches your content once, at build time, and writes plain HTML files. After that, visitors get those files. The CMS is not involved.
You have three ways to get new content onto the site:
| Approach | How it works | Best for |
|---|---|---|
| Rebuild on publish | The CMS calls a deploy hook, the host rebuilds everything | Small and medium sites, the simplest setup |
| Refresh one page | A webhook handler you write tells the framework to refresh a single page | Next.js sites with many pages |
| Render on request | The server reads the CMS API on each visit, or on a short cache | Content that changes often |
This guide covers the first one, which is what most solo sites need. You do not write any code.
What a deploy hook is
A deploy hook is a URL. When something sends it a POST request, your host starts a new build of your site. Vercel describes it as a URL that triggers a new deployment of a specific Git branch. Netlify calls the same idea a build hook, and Cloudflare Pages offers deploy hooks too.
Because the URL itself is the secret, anyone who has it can start builds. Keep it out of public repositories.
Step 1: create the hook at your host
Create a deploy hook in your project settings and give it a name such as "SharpWrite publish". Choose the branch you deploy from, usually main. Copy the URL.
Menu names change, so search your host's docs for "deploy hook" (Vercel, Cloudflare Pages) or "build hook" (Netlify) if you cannot find the setting.
Step 2: add it as a webhook in the CMS
In SharpWrite, open Webhooks, add a webhook and paste the URL. From then on SharpWrite sends a POST when an entry is published, changed, unpublished or deleted.
A deploy hook does not need the signature check, so there is nothing else to configure.
Step 3: test it
- Publish a small change to any entry.
- Open your host's deployments page. A new build should appear shortly after you publish.
- When it finishes, reload your site.
SharpWrite keeps the last 25 deliveries of each webhook, so if no build appeared you can see what the host answered.
Three gotchas that cause stale pages
The CMS API can be cached for a moment
After you publish, the entry shows up in the public API within about 30 seconds, because API responses can be cached for that long. If a build ever picks up the previous version of an entry, check this first. Publishing again, or re-running the build, fixes it.
A wrong or truncated URL fails silently
Hosts answer a bad hook URL with an error, and your site simply does not update. Paste the whole URL with no spaces. A failing webhook never blocks publishing in SharpWrite, which is good for your workflow and also means you will not notice the failure unless you look at the delivery list.
Every publish starts a build
Publish ten entries in a row and you start ten builds. Check how your host handles queued builds and what its build limits are, especially if you publish in bursts. For a big batch, publish the entries close together, at the end of your editing session.
Handling the webhook yourself
If you want to refresh one page instead of the whole site, point the webhook at your own endpoint and verify the signature first. SharpWrite signs each call with three headers: X-SharpWrite-Event, X-SharpWrite-Timestamp and X-SharpWrite-Signature. The signature is an HMAC-SHA256 of the timestamp, a dot and the raw body, using your signing secret.
import { createHmac, timingSafeEqual } from "node:crypto";
export function verify(secret, timestamp, rawBody, signature) {
const expected = "v1=" + createHmac("sha256", secret).update(`${timestamp}.${rawBody}`).digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(signature);
return a.length === b.length && timingSafeEqual(a, b);
}Always compare with timingSafeEqual, never ===, and verify before you do anything with the body. The exact format is in the API reference.
When you do not need a webhook at all
If your site renders on the server and reads the API on each request, new content appears as soon as the API serves it. Add a short cache so you stay inside the rate limit of 120 requests a minute per key, and skip the rebuild entirely. For a walkthrough of the static route, see the Astro blog guide. The patterns for Next.js and plain servers are on the Connect your site page.
You can try SharpWrite free for 7 days to set this up with a real site.
Frequently asked questions
How do I rebuild a static site when I publish in my CMS?
Create a deploy hook at your host, which is a URL that starts a build, and add that URL as a webhook in your CMS. The CMS calls it when you publish, and the host rebuilds the site.
What is a deploy hook?
A deploy hook is a private URL that starts a new deployment when it receives a POST request. Vercel and Cloudflare Pages call them deploy hooks, and Netlify calls them build hooks.
Why is my site not updating after I publish?
Check that the webhook URL is complete and correct, that the webhook is enabled, and that your host started a build. If the build ran but showed old content, the CMS API response may have been cached for a few seconds. Publish again or re-run the build.
Does the webhook need a signature check for a deploy hook?
No. A deploy hook only starts a build and carries no content, so SharpWrite does not require you to verify a signature. If you handle the webhook in your own code, verify the signature before using the data.
How many webhooks can I add in SharpWrite?
Up to 5 per site. SharpWrite keeps the last 25 deliveries of each so you can see what went wrong, and a failing webhook never blocks publishing.