Triggering Gatsby Rebuilds on a Schedule

Spencer Canner
2 min readJul 18, 2022

Learn how to configure your Gatsby.js site to rebuild on a schedule using Vercel and IFTTT.

Gatsby.js is a great tool for building static sites. The caveat is that it only fetches content at build time, so you generally shouldn’t be fetching data on-demand when a user visits your site. This works perfectly for something like a blog, where you are in control the content changes and can trigger a rebuild every time you update the content. However, if you’re relying on an external API or data source, you might not know when the data has changed. To help with this, you can leverage an automation tool such as IFTTT to send a post request to your Vercel build URL on a specific schedule. This will ensure that your site is checking for updated data at regular intervals, so you can serve the freshest content to your users.

To start create accounts for these sites if you don’t have them already:

  • Vercel — used to deploy your Gatsby.js site. If you plan to rebuild your site frequently, I suggest using Vercel since they do not charge for build minutes. You can follow this guide to help you deploy your site using Vercel.
  • IFTTT — used to trigger post requests on a schedule.

Once your site is set up and deployed in Vercel, you should be able to create a Deploy Hook for your project. This will give you a link that you can hit, which will trigger a deployment for your project. For your Gatsby site, this means your build script will be rerun and your site…

--

--

Spencer Canner

Engineer with a passion for finding creative solutions to hard problems.