Discussion on deploying a portfolio built with Sanity and Gatsby to Netlify, including resolving errors related to url mismatch, image references, and invalid file names.
I understand your frustration with the Netlify deployment! The good news is that the project info displayed in your Sanity Studio dashboard (like the repository slug) is just for convenience and shouldn't affect your actual deployment. Let me help you troubleshoot both issues.
About the Dashboard Project Info
The project info widget in Sanity Studio is purely informational - it displays metadata about your project but doesn't control how your site deploys. If you used one of Sanity's starter templates that includes a dashboardConfig.js file (common in older Sanity v2 projects), this is where that repository information is stored.
If you want to update it for consistency, you can:
- Look for a
dashboardConfig.jsfile in your studio folder (usually in the root or aconfigdirectory) - Find the
projectInfoWidgetconfiguration and update the repository slug to match your new GitHub URL - The configuration typically looks something like this:
{
name: 'project-info',
options: {
data: [
{
title: 'GitHub repo',
value: 'your-username/your-repo-name',
category: 'Code'
}
]
}
}However, this won't fix your deployment issue - it's just cosmetic.
Troubleshooting Your Netlify Deployment
The real issue is your frontend build failing on Netlify. Here are the most common causes with Gatsby + Sanity deployments:
1. Environment Variables Missing Make sure you've added your Sanity project ID and dataset name to Netlify's environment variables:
- Go to Site settings → Environment variables in Netlify
- Add
SANITY_PROJECT_IDandSANITY_DATASET(usually "production") - Add
SANITY_TOKENif your content requires authentication
2. Build Command Issues
- Check that your build command in Netlify is correct (usually
gatsby buildornpm run build) - Verify your Node version - Gatsby may require a specific version. You can set this with a
.nvmrcfile or in Netlify's build settings
3. Check the Build Logs The actual error message in Netlify's build logs will tell you exactly what's failing. Look for:
- Missing dependencies (
npm installoryarn installfailures) - GraphQL query errors (often from Sanity schema changes)
- API token/authentication issues
- Memory or timeout errors
4. Repository URL Mismatch Since you changed your GitHub repo URL, make sure Netlify is pointing to the correct repository:
- Go to Site settings → Build & deploy → Build settings
- Under "Repository," click "Link to a different repository" if needed
- The dash in your repo name shouldn't cause issues - GitHub and Netlify handle URL encoding automatically
5. CORS Configuration If you're getting API errors, you may need to add your Netlify URL to your Sanity project's CORS origins:
- Go to manage.sanity.io
- Select your project
- Go to Settings → API → CORS Origins
- Add your Netlify URL (both the temporary
.netlify.appURL and any custom domain)
The specific error message in your Netlify build logs will point you to the exact issue. If you share that error here, the community can give you more targeted help!
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.