Watch a live product demo 👀 See how Sanity powers richer commerce experiences

How to deploy Gatsby sites using official Sanity starter templates

24 replies
Last updated: Nov 30, 2020
Recently started to play with sanity and gatsby.js for a new project I want to work on. On your site I noticed that you have a few templates up with next.js and gatsby for ecommerce/blog sites. I set up the gatsby template and deployed it and everything but I can seem to understand why when I update data in the Studio, the only way to update data on the front-end is to redeploy. Is this supposed to be happening? Or should it update dynamically. I know its using SSR but I thought that there would be some sort of "incremental static regeneration".

Sorry if this is a bad question, I'm just really having trouble understanding.
Nov 30, 2020, 2:18 AM
I think you’re asking why it doesn’t build automatically when you update content? In that case, you need to set it up to trigger a build when you publish content in the studio. It’s in in settings > API > Add new webhook, you get the webhook from Netlify and copy/paste it there.
If that’s not what you mean then disregard
Nov 30, 2020, 2:50 AM
Yes, thank you for the response! I managed to add the webhook to the API settings, but it still doesn't trigger a new build when I publish something new.
Nov 30, 2020, 4:43 AM
You’re publishing from the actual studio, not a local server setup? And you grabbed the webhook from the Gatsby frontend, not the studio?
Nov 30, 2020, 4:47 AM
It’s the frontend that needs to re-build for the changes to display
Nov 30, 2020, 4:47 AM
Yeah, I was getting the hook from netlify, for some reason it keeps rebuilding the studio and not the front-end
Nov 30, 2020, 4:48 AM
and yes--not local server
Nov 30, 2020, 4:49 AM
Are you sure you set up the webhook on the Gatsby build? I haven’t used the Gatsby starter, I use 11ty, but if I’m not mistaken they both deploy two Netlify builds one for the frontend one for the studio. It sounds like maybe you set up the webhook on the studio build? If that’s not it I’m not sure
Nov 30, 2020, 4:51 AM
Yeah--I got it to work , it was my fault, grabbed the wrong webhook
Nov 30, 2020, 4:53 AM
however, it still takes forever to rebuild
Nov 30, 2020, 4:53 AM
I did exactly the same thing when I set mine up for the first time. 😂
Nov 30, 2020, 4:55 AM
Nov 30, 2020, 4:55 AM
It does that when it’s waiting for another build to finish
Nov 30, 2020, 4:58 AM
got it, yeah is it supposed to take a while to re-deploy? or is there any way to get quicker updates through this approach?
Nov 30, 2020, 4:59 AM
There are different things you can do to minimize build time, but in general it’s going to take a couple minutes for smaller sites. I’ve heard of larger sites taking quite a lot of time to build.
Nov 30, 2020, 5:02 AM
Once your site scales to the point where build time is a real issue, you can split it into smaller micro-sites so that only the parts you update are re-built (for instance, separating a site’s blog and store). Netlify’s free tier is 300 build minutes per month, I’ve yet to exceed that running two smaller sites
Nov 30, 2020, 5:04 AM
ah okay, makes sense. my usecase is an eCommerce website, but taking into consideration, every time an item is bought it would have to redeploy to update quantity on an item?
Nov 30, 2020, 5:06 AM
I don't think waiting for it to rebuild for 2 minutes will work, unless I'm thinking of it completely wrong.
Nov 30, 2020, 5:06 AM
I haven’t yet built an eCommerce app with JAMstack so I’m not 100% sure how it works, but I think that’s handled by whichever API is running your store. Again I’m not 100%, don’t want to give you bad info
Nov 30, 2020, 5:09 AM
Got it, no problem. I appreciate your help otherwise!
Nov 30, 2020, 5:10 AM
Of course! This slack channel has helped me a whole lot so I try to pay it forward whenever possible. 😁
Nov 30, 2020, 5:11 AM
Re: build time, you might want to check into Gatsby Cloud and incremental builds (can also make it work on Netlify).
Also, check if the build script clears the cache and that you also check in package-lock files so it doesn't need to reinstall all that stuff everytime.
Nov 30, 2020, 12:38 PM
Some data is simply too dynamic, and it no longer makes sense to generate static sites for it. "Items left in stock" is probably a good example (unless you stock something that sells very rarely..)
You should probably go for an API-type solution
Nov 30, 2020, 12:44 PM
You may want to watch how was made:

user G
goes over a fair amount of details on how it was put together and the considerations needed.
Nov 30, 2020, 1:45 PM
Awesome, thank you all for the replies! I really appreciate it.
Nov 30, 2020, 8:59 PM – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
After adding the subtitle and running this code npm run graphql-deploy It does nothingSep 15, 2020
how to limit a reference to just one entry in Studio reference input side versus the default as-many-entries-as-you-fill-in-an-array...Sep 18, 2020
Is it possible to fetch more than one "_type" using GROQ?Nov 2, 2020
I want to add a view with the Structure builder (S.view.component) where I list similar documents based on the title. What...Sep 23, 2020
Is there a structure builder example where the format of each preview for the document list is modified?Feb 3, 2021
I have an array of references to a country schema type but it always just returns NULL values for meJan 30, 2021
Hi, I need help with a query for getting the url of an image asset. Here is what I've been trying, but I only get the _ref...Dec 1, 2020
Sanity UI looks brilliant :smiley: Is something like the current date picker possible at the moment? I’m not sure if anicon...Dec 21, 2020
Hey everyone. I have been coding and may have potentially accidentally deleted something. Does anyone know how to resolve...Dec 26, 2020
Hello everyone and happy new year :raised_hands::skin-tone-2:, I have a problem with outputting Portable Text :disappointed:...Jan 1, 2021

Related contributions

Jamstack Explorers
- Made with Sanity

Jamstack Explorers is a free learning platform created by the team at Netlify to chart a course through the amazing offerings in the Jamstack ecosystem

Go to Jamstack Explorers

- Made with Sanity

Complex product offering with nested product structure and tiered pricing.

Kevin Green
Go to Occo

Figma Config
- Made with Sanity

Website for Config, the global design conference by Figma.

Corey Ward
Go to Figma Config