Guides & Tutorials

Enable Gatsby Incremental Builds on Netlify

Guides & Tutorials

Enable Gatsby Incremental Builds on Netlify

Gatsby has a great feature called incremental builds, an improvement that reduces the amount of work required to build a Gatsby site. In this post, we’ll learn how to ensure you’re able to reliably use Gatsby incremental builds on Netlify.

Step 1: Upgrade to a recent Gatsby version

At the time of writing, Gatsby 5 is the latest Gatsby version and should be used. Versions below Gatsby 4 have been dropped from the official support cycle. Incremental build should work from Gatsby v2.20.4, but this guide might not apply or work correctly for those sites.

# this will upgrade Gatsby to v5
npm install gatsby@5

Step 2: Make sure you're using gatsby-adapter-netlify

On Netlify, since Gatsby v5.12, Gatsby would automatically use gatsby-adapter-netlify and handle the required configuration for you. If you’re using Gatsby versions lower than v5.12, make sure you’re using gatsby-plugin-netlify and @netlify/plugin-gatsby.

Step 3: Make a change in your CMS and see the incremental builds!

Once we’ve made the above changes, our Gatsby site will run with incremental builds enabled! This means that changes from a supported CMS - Gatsby supports Contentful, WordPress, Drupal and some other CMSs officially, while there might be community-maintained source-plugins available for other CMSs — Gatsby will only rebuild the parts of the site affected by the changed data.

If we look at our build logs, the first build will show a full build with all of our pages:

2:00:43 PM: info Done building in 41.429647017 sec
2:00:43 PM: info Built pages:
2:00:43 PM: Updated page: /design-research-program
2:00:43 PM: Updated page: /offline-plugin-app-shell-fallback/
2:00:43 PM: Updated page: /
2:00:43 PM: Updated page: /404/
2:00:43 PM: Updated page: /404.html

On repeat builds, we can see that the Gatsby build is much faster and only rebuilds the page that was changed:

2:03:56 PM: info Done building in 17.691847403 sec
2:03:56 PM: info Built pages:
2:03:56 PM: Updated page: /design-research-program

You can use Gatsby incremental builds today!

If you’ve got a Gatsby site, you can enable incremental builds today!

Give it a try, and enjoy builds that make your blazing fast Gatsby site even more blazinger! 🔥

Keep reading

Recent posts

Book cover with the title Deliver web project 10 times faster with Jamstack enterprise

Deliver web projects 10× faster

Get the whitepaper