Trigger Netlify Builds when content changes in Contentful

Khaled Garbaya
InstructorKhaled Garbaya

Share this video with your friends

Send Tweet
Published 3 years ago
Updated a year ago

Netlify will automatically build your Gatsby website whenever you push new code to your repository but what about content changes in Contentful. In this lesson, you will learn how to use Contentful webhook feature to trigger a Netlify build whenever you publish or delete new content on Contentful

Instructor: [00:00] Netlify will rebuild our website whenever we push new code, but we want also to trigger the rebuild whenever we do content changes. We can do that using what's called webhooks. Let's go to deploy settings, and in build hooks, you can click add build hook. Let's call this Contentful and hit save.

[00:28] We grab this URL and go to Contentful. In there, we go into settings, webhooks, and we add webhook. This one, we'll call it Netlify. We will paste our URL in here, and we select specific events that will trigger this rebuild.

[00:53] We want that whenever we publish a new entry, a content type, or an asset. We can go to publish and check these. Also, in onPublish and onDelete. Let's hit save, and to test our webhook, we can go to the content. Go to this lesson.

[01:23] Let's change something. Let's remove this question mark, and we hit publish. Now, when we go back to Netlify, and go to deploys, you can see that here, it's triggered by Contentful. Now, it's rebuilding our website.

[01:50] When we preview this, we should see the new content reflected in the website.