Build Hooks and Webhooks
What you'll learn: How to automatically rebuild and redeploy your static site whenever content changes, using webhooks to trigger your build process.
The Problem with Manual Rebuilds
With static site generation, your site is built once and served as static files. But what happens when your content editor updates an article in your CMS? Your site still shows the old version until you manually trigger a new build. That's inefficient and error-prone.
How Webhooks Solve This
A webhook is like a doorbell for your build system. When something happens in your CMS (content updated, published, deleted), the CMS "rings the bell" by sending an HTTP request to a special URL you've configured. This URL is your build hook — an endpoint provided by your hosting platform (Netlify, Vercel, etc.) that triggers a new build automatically.
The Flow
- Content editor publishes a new blog post in your headless CMS
- CMS detects the change and sends a POST request to your build hook URL
- Your hosting platform receives the webhook and starts a fresh build
- Build process fetches the updated data from your CMS
- New static files are generated and deployed
- Your site now reflects the latest content — all without manual intervention
Setting It Up
Most headless CMSs have a "Webhooks" section in their settings where you paste your build hook URL. Your hosting platform provides this URL in their deployment settings. It's typically a secure, unique endpoint like https://api.netlify.com/build_hooks/abc123xyz.
You can configure multiple webhooks for different events (publish, unpublish, scheduled releases) and even add delay logic to batch multiple rapid changes into a single build.
Key Takeaway: Webhooks connect your content source to your build pipeline, enabling automatic rebuilds whenever content changes, making SSG feel dynamic without sacrificing performance.