Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

Add a Webhook to fix Generator Issues

6 replies
Last updated: Aug 3, 2020

I'm having issues with both Sanity's Eleventy generator as well as their Gridsome generator. New published posts added to Studio are not being displayed on the front end. I thought maybe the problem was me. So, I tried Sanity's Nuxt generator, and that works as advertised. Has anyone had the same experience?

Aug 3, 2020, 2:37 PM

BTW, my local environment doesn't have this issue. I can see all my updated posts locally. But, none of this helps me if I can't see these posts/changes on my remote site. And then I thought maybe the issue was with Netlify. But, all I see is 2 deploy builds since 2 days ago regarding template changes, not content changes.

Aug 3, 2020, 3:04 PM

Hi Scott, whether your front-end deploys automatically on content changes in Sanity depends on if you have a webhook set up for this.
For more information on webhooks:
https://www.sanity.io/docs/webhooks
To set up a webhook, enter your project on
manage.sanity.io and go to Settings > API > Webhooks > Add new webhook. If you point this to a Netlify build endpoint (or a custom function if you prefer), it should automatically trigger builds.
Bear in mind that this can easily use up your build minutes on Netlify if you publish content frequently. As an alternative, you might want to consider manually triggering a deploy hook instead whenever you finish editing and want to publish changes to your front-end. There is a Netlify widget for the Studio that allows you to do just that from the Dashboard:
https://www.npmjs.com/package/sanity-plugin-dashboard-widget-netlify 🙂

Aug 3, 2020, 3:34 PM

Hi Scott, whether your front-end deploys automatically on content changes in Sanity depends on if you have a webhook set up for this.
For more information on webhooks:
https://www.sanity.io/docs/webhooks
To set up a webhook, enter your project on
manage.sanity.io and go to Settings > API > Webhooks > Add new webhook. If you point this to a Netlify build endpoint (or a custom function if you prefer), it should automatically trigger builds.
Bear in mind that this can easily use up your build minutes on Netlify if you publish content frequently. As an alternative, you might want to consider manually triggering a deploy hook instead whenever you finish editing and want to publish changes to your front-end. There is a Netlify widget for the Studio that allows you to do just that from the Dashboard:
https://www.npmjs.com/package/sanity-plugin-dashboard-widget-netlify 🙂

Aug 3, 2020, 3:34 PM

Thanks

user M
I see that explanation now. Plus, that explains why my Netlify dashboard widget in Studio is broken. It probably needs to be configured yet.

Aug 3, 2020, 3:53 PM

Sorry about that Scott, it’s an issue we’re resolving at the moment to make it set up the widget automatically. Let me know if you need any pointers while configuring. Also, there’s this thread to reference: https://sanity-io-land.slack.com/archives/C9Z7RC3V1/p1595526846041300

Aug 3, 2020, 4:00 PM

Great! That's very helpful

user M

Aug 3, 2020, 4:03 PM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.