Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Trigger Netlify Builds when content changes in Contentful

    Khaled GarbayaKhaled Garbaya

    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



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    Instructor: 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.

    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.

    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.

    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.

    When we preview this, we should see the new content reflected in the website.