Can content be added without rebuilding in GatsbyJS on Netlify? Discussion of using Contentful and Sanity.io for triggering rebuilds and improving dev experience.
Not a dumb question at all! This is actually one of the most common questions when working with static site generators like Gatsby. Let me break down your options:
The Short Answer: With traditional Gatsby static site generation (SSG), you'll need to rebuild to see content updates. However, there are several approaches to make this seamless or even eliminate rebuilds in some cases.
Your Best Options:
1. Automated Rebuilds with Webhooks (Most Common)
The standard approach is to set up webhooks in Sanity that automatically trigger a Netlify build whenever you publish content changes:
- Configure a webhook in your Sanity project settings that points to a Netlify build hook URL
- When you publish/update content in Sanity, it automatically triggers a new build
- Netlify's Git-based workflow makes this process fast and reliable
- For a portfolio site, builds typically complete in under a minute
This gives you the benefits of static site generation (speed, security, low cost) while keeping content updates relatively quick.
2. Gatsby's Server-Side Rendering (SSR)
Gatsby v4+ supports SSR using getServerData(), which fetches fresh content on every page request—no rebuild needed. However, there's a significant caveat: Netlify's support for Gatsby SSR is limited. You'll need the @netlify/plugin-gatsby and it only works in production, not during local development.
3. Deferred Static Generation (DSG)
DSG generates pages on-demand when first requested, then caches them. This helps with large sites but doesn't solve the content update problem—you'll still need rebuilds to update existing pages.
4. Client-Side Data Fetching
For specific dynamic sections (like a "latest projects" widget), you can fetch data directly from Sanity's Content Lake API using JavaScript on the client side. The rest of your site remains static.
My Recommendation for Your Portfolio:
Use automated webhooks with Netlify build hooks. It's the most reliable, well-supported approach for Gatsby + Netlify. Here's why:
- Portfolio sites typically build quickly (seconds to a couple minutes)
- You get the full benefits of static site generation—excellent performance, security, and SEO
- Updates are automatic—just publish in Sanity and your site rebuilds
- Netlify's platform handles this workflow seamlessly with deploy previews and atomic deploys
If you absolutely need instant updates without any build step, you might want to consider Next.js instead, which has much better SSR support and works excellently with both Vercel and Netlify.
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.