
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI can see you're dealing with a common confusion when first deploying a Gatsby site with Sanity to Netlify! Let me break this down clearly for you.
First, it's important to understand that Sanity Studio (the content editing interface) and your Gatsby website (the frontend) are two separate things:
Sanity Studio - This is where you edit content. It can be hosted either:
yourname.sanity.studio (free and recommended)Gatsby Website - This is your actual website that pulls content from Sanity's API and displays it to visitors. This is what you're deploying to Netlify.
Your Gatsby site needs to be configured to fetch data from Sanity. You need to install and configure the gatsby-source-sanity plugin in your Gatsby project.
npm install gatsby-source-sanitygatsby-config.js:module.exports = {
plugins: [
{
resolve: 'gatsby-source-sanity',
options: {
projectId: 'your-project-id',
dataset: 'production',
apiVersion: '2023-05-03', // use today's date
// Optional: if you have a private dataset or want draft previews
token: process.env.SANITY_READ_TOKEN,
watchMode: true, // enables hot-reloading in development
overlayDrafts: true, // shows drafts in development
},
},
],
}cd your-sanity-studio-folder
sanity graphql deployCI/CD stands for "Continuous Integration" and "Continuous Deployment" - it's just a fancy way of saying "automatically build and deploy your site whenever you push code to GitHub." Netlify does this automatically when you connect your GitHub repo, so you don't need to worry about this terminology.
When the docs mention creating a token and adding @sanity/cli as a devDependency:
Token: Create a read token in your Sanity project at manage.sanity.io (Settings → API → Add new token). This is only needed if your dataset is private or you want to preview draft content.
Add the token to Netlify: Go to your Netlify site settings → Environment variables → Add:
SANITY_READ_TOKEN@sanity/cli as devDependency: This should be added to your Gatsby project's package.json, not your Studio project. You can add it with:
npm install --save-dev @sanity/cliThe confusion in the docs about "serve the bundle" vs "CI/CD flow":
"Serve the bundle" - This refers to deploying your Sanity Studio itself (the editing interface). If you run sanity deploy, it hosts your Studio at yourname.sanity.studio. This is separate from your Gatsby site.
"CI/CD flow" - This refers to automatically deploying your Gatsby website whenever you push code. Netlify handles this automatically when you connect your GitHub repo.
For your situation, I recommend:
sanity deploy from your studio folder) - it's free and easiestThis way, you edit content at yourname.sanity.studio, and your public website is on Netlify, automatically rebuilding when you push code changes to GitHub.
Hosting your Studio on Netlify vs Sanity's hosting doesn't affect how your Gatsby site fetches data - both setups make API requests to Sanity's Content Lake (the database). The Studio is just an editing interface; the actual content always lives in Sanity's cloud.
The main reason to host Studio on Netlify would be if you want a custom domain for your editing interface, but Sanity's free *.sanity.studio hosting works perfectly fine for most use cases. As mentioned in this community answer, where you host your Studio is a React SPA (single page application) choice - it doesn't change the fact that API requests to Sanity still need to be made to fetch your content.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content backend


The only platform powering content operations


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store