This section is basically reproduces with extremely minor edits from Bryan Robinson's excellent Smashing Magazine write up.
Make sure you have a Netlify account! In Netlify’s Dashboard, you need to connect the new repository to a new site in Netlify.
Once that’s hooked up, you need to tell Netlify how to build your Jackyll project. In the dashboard, head to: Settings > Build & Deploy > Build Settings. In this area, we need to change your “Build command” to “node index.js” and your “Publish directory” to “./dist” (or whatever your output directory is called).
Next, you can set up a webhook so that Netlify will publish the site upon changes to the Sanity CMS.
To do that, set up a Webhook to notify Netlify to rebuild. A Webhook is a URL that can be programmatically accessed by a different service (such as Sanity) to create an action in the origin service (in this case Netlify).
You can set up a specific “Build hook” in your Netlify dashboard at Settings > Build & Deploy > Build hooks. Add a hook, give it a name and save. This will provide a URL that can be used to remotely trigger a build in Netlify.
Next, you need to tell Sanity to make a request to this URL when you publish changes.
You can use the Sanity CLI to accomplish this. Inside of your /studio
directory, you can run sanity hook create
to connect. The command will ask for a name, a dataset, and a URL. The name can be whatever you’d like, the dataset should be production
for your product, and the URL should be the URL that Netlify provided.
I think that's it?