Issue with content publishing in Sanity + Eleventy + Netlify setup
I can see you're experiencing a common issue with the Sanity + Eleventy + Netlify setup where published posts aren't appearing on your site. This typically happens because there's a disconnect between when you publish content in Studio and when your Eleventy site rebuilds to fetch that new content.
The key issue is that Eleventy is a static site generator - it fetches content from Sanity at build time, not in real-time. When you publish a post in Studio, your Netlify-hosted website doesn't automatically know to rebuild and fetch the new content.
The Problem
When you hit "Publish" in your Sanity Studio, the content is saved to Sanity's Content Lake, but your Eleventy site on Netlify still shows the old static HTML from the last build. Your site needs to be rebuilt to query Sanity for the new post and generate the updated HTML.
The Solution
You need to trigger a rebuild of your Netlify site after publishing content. Here are your options:
1. Manual Deploy (Quick Test)
Go to your Netlify dashboard, find your web project (not the studio), and click "Trigger deploy" → "Deploy site". After the build completes (usually 1-2 minutes), your new post should appear. This confirms everything is working.
2. Set Up Automated Rebuilds with Webhooks
The standard, production-ready approach is to use GROQ-powered webhooks to automatically trigger Netlify rebuilds when content is published. Here's how:
- Go to your Netlify site settings → Build & deploy → Build hooks
- Click "Add build hook" and give it a name like "Sanity Content Update"
- Copy the webhook URL Netlify provides
- Go to your Sanity project at sanity.io/manage → select your project → API → Webhooks
- Create a new webhook with the Netlify build hook URL
- Configure it to trigger on document changes for your post type
This way, every time you publish content in Sanity, it automatically triggers a Netlify rebuild, and your new post appears within a few minutes. This is the standard pattern used in production by many Sanity sites.
3. Alternative: Sanity Functions (Experimental)
You can also use Sanity Functions, which are serverless, event-driven code modules that respond to content changes and can trigger external services like your Netlify build hook. While Functions offer more flexibility for complex workflows and run directly on Sanity's infrastructure, they are currently an experimental feature with APIs subject to change. For straightforward build triggering, webhooks are the more established and reliable option.
Troubleshooting: Why Your Post Might Still Not Show
If rebuilding doesn't fix it, check these common issues:
Missing
publishedAtdate: The default GROQ query typically filters forpublishedAt < now(). Make sure your post has a publish date that's in the past, not the future.Missing slug: The query also filters for
defined(slug). Verify your post has a slug defined.Draft vs Published: Ensure you clicked the "Publish" button (not just "Save"). The query specifically looks for published documents with
_type == "post".URL structure: Individual posts should be at
/blog/[your-slug]/. If you're getting 404s on the individual post route, the slug might not be generating correctly.
Verify Your Content Exists
You can verify your content is actually in Sanity by using the Vision plugin in your Studio. Look for the "Vision" tab and run this query:
*[_type == "post" && defined(slug)] | order(publishedAt desc)This will show you all posts with slugs, regardless of publish status, so you can confirm your test post exists in Sanity.
Quick Fix Right Now
- Go to your Netlify dashboard
- Find your web project (should be something like
sanity-eleventy-blog-web) - Click "Trigger deploy" → "Deploy site"
- Wait for the build to complete
- Check your site - your post should now appear
Once you confirm this works, set up the webhook automation so future posts appear automatically without manual intervention. Webhooks are fully supported and work reliably for production sites with static site generators like Eleventy.
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.