Gatsby build issues with Sanity blog starter project

12 replies
Last updated: Nov 29, 2025
Hey all! Has anyone had any build issues when trying to run a gatsby build on the Sanity blog starter project? I am getting this…
AI Update

Hey! Gatsby build issues with Sanity starters can definitely be frustrating. Based on what you're experiencing, there are a few common culprits to check:

Most Common Build Errors

1. Missing or Invalid Token for overlayDrafts

If you're seeing overlayDrafts is set to true, but no token is given, you need to add an API token to your gatsby-source-sanity configuration. Create a read token from the API tab in your Sanity project and add it to your gatsby-config.js:

{
  resolve: 'gatsby-source-sanity',
  options: {
    projectId: 'your-project-id',
    dataset: 'production',
    token: 'your-read-token-here',
    overlayDrafts: true,
    watchMode: true
  }
}

2. GraphQL API Not Deployed

The ERROR #gatsby-source-sanity_drafts.10001 error means your GraphQL API hasn't been deployed yet. Run this from your Sanity Studio directory:

sanity graphql deploy

3. Plugin Compatibility Issues

If you're getting window.URL.createObjectURL errors, this is typically caused by outdated plugins. The sanity-plugin-mapbox-input plugin has a known issue with newer versions of mapbox-gl. This plugin is no longer maintained, so you'll need to either:

  • Pin mapbox-gl to a compatible version in your package.json
  • Find an alternative plugin for map functionality
  • Remove the plugin if you're not using it

4. Outdated Packages

The Sanity blog starter might be using older versions. Check your package versions:

npm ls gatsby-source-sanity

The latest gatsby-source-sanity version should be compatible with recent Gatsby versions. Consider updating:

npm update gatsby-source-sanity

Quick Troubleshooting Steps

  1. Make sure your GraphQL API is deployed: sanity graphql deploy
  2. Add a read token to your gatsby-source-sanity config
  3. Check for outdated or unmaintained plugins (especially mapbox-related ones)
  4. Clear Gatsby cache: gatsby clean
  5. Rebuild: gatsby build

If you're still having issues, sharing the specific error message would help diagnose further. The Sanity Discord community is also super helpful for real-time troubleshooting!

Show original thread
12 replies

Sanity – Build the way you think, not the way your CMS thinks

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.

Was this answer helpful?