🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

How to deploy Sanity Studio to Netlify in a monorepo with Gatsby

17 replies
Last updated: Aug 20, 2020
hi, I followed the Sanity-Gatsby tutorial below and was able to deploy to Netlify, but couldn’t figure out the part about deploying the Studio to Netlify:
Aug 20, 2020, 1:47 AM
Hi User, you can deploy your Studio to Netlify choosing the New GitHub site option, if you run
sanity deploy
on your folder, your Studio will be deployed to <your-project>.sanity.studio
Aug 20, 2020, 3:19 AM
user A
, thanks for the response … am trying that right now … screenshot below of my Netlify new github site config … what should I put for
Publish directory
? Everything else looks OK?
Aug 20, 2020, 3:27 AM
If you have a repo just for your studio, the publish directory will be
if you have a repo with both your studio and your gatsby site, the publish directory will be something like this
Aug 20, 2020, 3:31 AM
your build command will be npm/yarn build, also make sure you have
user U
/cli in your dependencies
Aug 20, 2020, 3:32 AM
here’s an example of my netlify config and package.json in case in useful for you
Aug 20, 2020, 3:34 AM
hmmm, a little confused … I’m working through the example gatsby-sanity project at https://github.com/sanity-io/example-company-website-gatsby-sanity-combo.git , which is a monorepo that has both gatsby (in the /web folder) and the sanity studio (in the /sanity) folder … I forked this repo and pushed it to my a repo on my github account … I was able to deploy the static site and wondering how to deploy the studio … do I need to make a separate repo with just the /sanity folder?
Aug 20, 2020, 3:43 AM
sorry, a little confused
Aug 20, 2020, 3:43 AM
no, you can work with that repo, your base directory will be studio and your public folder will be dist, it works just like the deployment of the static site
Aug 20, 2020, 3:46 AM
if you still need help, you can check this blogpost 🙂

Aug 20, 2020, 3:58 AM
I set up the deploy settings for the studio as follows:
Aug 20, 2020, 4:09 AM
looks right? Then I saved the settings and triggered the deploy
Aug 20, 2020, 4:09 AM
Then saw this unusual item from the deploy log:

9:05:52 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: 'web' versus 'Studio' in the Netlify UI
9:05:52 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'web/public' versus 'dist' in the Netlify UI
Aug 20, 2020, 4:10 AM
Like it detected the
file in the git root and ignored my
Base directory
Aug 20, 2020, 4:11 AM
When I click on the URL of the deployed site, I see the static site built by Gatsby instead of the Sanity Studio: https://pensive-perlman-798bc1.netlify.app/
Aug 20, 2020, 4:12 AM
your configuration looks right, I am not sure if you need the base directory in lowercase
, about the
, you can have one in each folder (without the base specification) and remove the
from the root
Aug 20, 2020, 4:42 AM
user A
, I removed the netlify.toml from my git root, pushed back up to git, and the studio (and static site) are working now!
Aug 20, 2020, 5:19 AM
Great! 🙌
Aug 20, 2020, 5:35 AM

Sanity– build remarkable experiences at scale

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

Was this answer helpful?