Sanity Setup
Sanity Setup
Section titled “Sanity Setup”The Podcast Framework template comes with Sanity Studio pre-configured. You just need to create a Sanity project and add your credentials.
Prerequisites
Section titled “Prerequisites”- Sanity account (sign up free)
- Podcast Framework template cloned
- Node.js 18+ installed
Quick Setup (3 Steps)
Section titled “Quick Setup (3 Steps)”Step 1: Create Sanity Project
Section titled “Step 1: Create Sanity Project”- Go to sanity.io/manage
- Click “Create project”
- Project name: my-podcast (or your podcast name)
- Dataset: production (default)
- Copy your Project ID (looks like
abc123xyz)
Step 2: Configure Environment Variables
Section titled “Step 2: Configure Environment Variables”Copy the template and add your credentials:
cp .env.template .env.localEdit .env.local and add your Project ID:
# For website (public - exposed to client)PUBLIC_SANITY_PROJECT_ID="abc123xyz" # ← Your Project ID here!PUBLIC_SANITY_DATASET="production"PUBLIC_SANITY_API_VERSION="2024-01-01"
# For Sanity Studio (server-side only)SANITY_PROJECT_ID="abc123xyz" # ← Same Project IDSANITY_DATASET="production"Step 3: Install Dependencies
Section titled “Step 3: Install Dependencies”npm installThat’s it! Studio is ready to use.
Running Sanity Studio
Section titled “Running Sanity Studio”Local Development
Section titled “Local Development”Start Studio locally:
npm run sanity:devVisit http://localhost:3333 - you should see Sanity Studio!
You should see:
- Episode (sidebar)
- Guest (sidebar)
- Host (sidebar)
- Podcast (sidebar)
- Contribution (sidebar)
- Theme (sidebar)
- Homepage Config (sidebar)
- About Page Config (sidebar)
Production Deployment
Section titled “Production Deployment”Deploy Studio to Sanity Cloud (free hosting):
npm run sanity:deployChoose a studio hostname:
Studio hostname: my-podcast✔ Deployed to https://my-podcast.sanity.studioNow you can access Studio from anywhere at your custom URL!
Creating Content
Section titled “Creating Content”Step 1: Create Podcast Document
Section titled “Step 1: Create Podcast Document”- Click “Podcast” in sidebar
- Click “Create new Podcast”
- Fill in required fields:
- Name: Your podcast name
- Tagline: Short tagline
- Description: Full description
- Is Active: Toggle ON if actively releasing episodes
- Optional fields:
- Upload logo
- Add Spotify, Apple Podcasts, YouTube URLs
- Add social links (Twitter, Discord)
- Click “Publish”
Step 2: Create Your First Episode
Section titled “Step 2: Create Your First Episode”- Click “Episode” in sidebar
- Click “Create new Episode”
- Fill in fields:
- Title: Episode title
- Slug: Auto-generated (or customize)
- Episode Number: 1, 2, 3, etc.
- Publish Date: When published
- Duration: MM:SS or HH:MM:SS format
- Description: Episode description
- Optional fields:
- Upload cover image
- Add Spotify/Apple/YouTube links
- Add show notes (rich text)
- Mark as featured
- Click “Publish”
Step 3: Create a Guest
Section titled “Step 3: Create a Guest”- Click “Guest” in sidebar
- Click “Create new Guest”
- Fill in fields:
- Name: Guest name
- Slug: Auto-generated
- Bio: Guest biography
- Optional fields:
- Upload photo
- Add Twitter handle
- Add website URL
- Add LinkedIn URL
- Click “Publish”
Step 4: Link Guest to Episode
Section titled “Step 4: Link Guest to Episode”- Go back to your episode
- Scroll to “Guests” field
- Click “Add item”
- Select the guest you created
- Click “Publish”
Verify Setup
Section titled “Verify Setup”Build your site to verify everything works:
npm run buildExpected output:
✓ Completed in 20s 12 page(s) builtStart dev server:
npm run devVisit http://localhost:4321 - your podcast site should display!
Sanity Studio Commands
Section titled “Sanity Studio Commands”The template includes npm scripts for working with Studio:
# Local developmentnpm run sanity:dev# → http://localhost:3333
# Deploy to Sanity Cloudnpm run sanity:deploy# → https://your-podcast.sanity.studio
# Build Studio for productionnpm run sanity:buildStudio Features
Section titled “Studio Features”Document Management:
- Create, edit, delete documents
- Rich text editing
- Image uploads with hotspot
- Reference relationships
- Draft/publish workflow
Collaboration:
- Real-time collaboration
- Change history
- Comment threads
- Permissions management
Vision Tool:
- Test GROQ queries
- Explore your dataset
- Debug query issues
Configuration Files
Section titled “Configuration Files”The template comes with Sanity pre-configured. Here’s what’s included:
sanity.config.ts
Section titled “sanity.config.ts”Main Sanity configuration (at project root):
import { defineConfig } from 'sanity';import { structureTool } from 'sanity/structure';import { visionTool } from '@sanity/vision';
// Import framework schemasimport { episode, guest, host, podcast, contribution} from '@rejected-media/podcast-framework-sanity-schema';
export default defineConfig({ name: 'default', title: 'My Podcast',
// Uses environment variables from .env.local projectId: process.env.SANITY_PROJECT_ID || '', dataset: process.env.SANITY_DATASET || 'production',
plugins: [ structureTool(), visionTool() ],
schema: { types: [ podcast, episode, guest, host, contribution, ] }});sanity/sanity.cli.ts
Section titled “sanity/sanity.cli.ts”CLI configuration for deployment:
import { defineCliConfig } from 'sanity/cli';
export default defineCliConfig({ api: { projectId: process.env.SANITY_PROJECT_ID || '', dataset: process.env.SANITY_DATASET || 'production' }});API Tokens
Section titled “API Tokens”Read Token (Public)
Section titled “Read Token (Public)”Used for fetching content (already configured):
PUBLIC_SANITY_PROJECT_ID="abc123" # Public, safe for clientPUBLIC_SANITY_DATASET="production"Write Token (Private)
Section titled “Write Token (Private)”Required for contribution forms:
- Go to sanity.io/manage
- Select your project
- Click API → Tokens
- Click “Add API token”
- Name: “Production Write Token”
- Permissions: Editor (read + write)
- Click “Add token”
- Copy the token (shows once!)
Add to .env:
SANITY_API_TOKEN="sk_..." # Keep secret!Datasets
Section titled “Datasets”Production Dataset
Section titled “Production Dataset”Default dataset for production content:
PUBLIC_SANITY_DATASET="production"Development Dataset
Section titled “Development Dataset”Create a development dataset for testing:
cd sanitynpx sanity dataset create developmentUse in development:
PUBLIC_SANITY_DATASET="development"Staging Dataset
Section titled “Staging Dataset”Create a staging dataset:
npx sanity dataset create stagingWorkflow:
development → staging → production (test) (review) (live)Importing Content
Section titled “Importing Content”Import Episodes from RSS
Section titled “Import Episodes from RSS”# Set RSS feed URLecho 'RSS_FEED_URL="https://yourpodcast.com/feed.xml"' >> .env
# Import episodesnpm run import:episodesThis script:
- Fetches RSS feed
- Parses episodes
- Creates Sanity documents
- Uploads to production dataset
Bulk Upload Guest Photos
Section titled “Bulk Upload Guest Photos”# Place photos in public/guests/# photos/danny-ryan.jpg
npm run upload:photosTroubleshooting
Section titled “Troubleshooting””Project not found”
Section titled “”Project not found””Check Project ID matches:
# List your projectsnpx sanity projects list
# Output:# my-podcast (abc123xyz) - YouCopy the Project ID to .env:
PUBLIC_SANITY_PROJECT_ID="abc123xyz"“Dataset not found”
Section titled ““Dataset not found””Create the production dataset:
cd sanitynpx sanity dataset create production“Schema deploy failed”
Section titled ““Schema deploy failed””Check you’re in the sanity directory:
cd sanitynpx sanity schema deploycd ..Studio shows “Invalid token”
Section titled “Studio shows “Invalid token””Check your token is valid:
- Go to sanity.io/manage
- Select your project
- API → Tokens
- Verify token exists and isn’t expired
- Regenerate if needed
Build fails with Sanity error
Section titled “Build fails with Sanity error”Check connection to Sanity:
# Test Sanity connectionnpx sanity checkNext Steps
Section titled “Next Steps”- Schemas - Understand schema structure
- Content Management - Add episodes and guests
- Theme Configuration - Customize your theme
- Homepage Configuration - Configure homepage
Related
Section titled “Related”- Sanity Helpers - Fetch content in your code
- Configuration - Environment variables
- Deployment - Production setup