Skip to content

Sanity Setup

The Podcast Framework template comes with Sanity Studio pre-configured. You just need to create a Sanity project and add your credentials.

  • Sanity account (sign up free)
  • Podcast Framework template cloned
  • Node.js 18+ installed
  1. Go to sanity.io/manage
  2. Click “Create project”
  3. Project name: my-podcast (or your podcast name)
  4. Dataset: production (default)
  5. Copy your Project ID (looks like abc123xyz)

Copy the template and add your credentials:

Terminal window
cp .env.template .env.local

Edit .env.local and add your Project ID:

Terminal window
# 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 ID
SANITY_DATASET="production"
Terminal window
npm install

That’s it! Studio is ready to use.

Start Studio locally:

Terminal window
npm run sanity:dev

Visit 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)

Deploy Studio to Sanity Cloud (free hosting):

Terminal window
npm run sanity:deploy

Choose a studio hostname:

Studio hostname: my-podcast
✔ Deployed to https://my-podcast.sanity.studio

Now you can access Studio from anywhere at your custom URL!

  1. Click “Podcast” in sidebar
  2. Click “Create new Podcast”
  3. Fill in required fields:
    • Name: Your podcast name
    • Tagline: Short tagline
    • Description: Full description
    • Is Active: Toggle ON if actively releasing episodes
  4. Optional fields:
    • Upload logo
    • Add Spotify, Apple Podcasts, YouTube URLs
    • Add social links (Twitter, Discord)
  5. Click “Publish”
  1. Click “Episode” in sidebar
  2. Click “Create new Episode”
  3. 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
  4. Optional fields:
    • Upload cover image
    • Add Spotify/Apple/YouTube links
    • Add show notes (rich text)
    • Mark as featured
  5. Click “Publish”
  1. Click “Guest” in sidebar
  2. Click “Create new Guest”
  3. Fill in fields:
    • Name: Guest name
    • Slug: Auto-generated
    • Bio: Guest biography
  4. Optional fields:
    • Upload photo
    • Add Twitter handle
    • Add website URL
    • Add LinkedIn URL
  5. Click “Publish”
  1. Go back to your episode
  2. Scroll to “Guests” field
  3. Click “Add item”
  4. Select the guest you created
  5. Click “Publish”

Build your site to verify everything works:

Terminal window
npm run build

Expected output:

✓ Completed in 20s
12 page(s) built

Start dev server:

Terminal window
npm run dev

Visit http://localhost:4321 - your podcast site should display!

The template includes npm scripts for working with Studio:

Terminal window
# Local development
npm run sanity:dev
# → http://localhost:3333
# Deploy to Sanity Cloud
npm run sanity:deploy
# → https://your-podcast.sanity.studio
# Build Studio for production
npm run sanity:build

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

The template comes with Sanity pre-configured. Here’s what’s included:

Main Sanity configuration (at project root):

import { defineConfig } from 'sanity';
import { structureTool } from 'sanity/structure';
import { visionTool } from '@sanity/vision';
// Import framework schemas
import {
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,
]
}
});

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'
}
});

Used for fetching content (already configured):

.env
PUBLIC_SANITY_PROJECT_ID="abc123" # Public, safe for client
PUBLIC_SANITY_DATASET="production"

Required for contribution forms:

  1. Go to sanity.io/manage
  2. Select your project
  3. Click APITokens
  4. Click “Add API token”
  5. Name: “Production Write Token”
  6. Permissions: Editor (read + write)
  7. Click “Add token”
  8. Copy the token (shows once!)

Add to .env:

Terminal window
SANITY_API_TOKEN="sk_..." # Keep secret!

Default dataset for production content:

Terminal window
PUBLIC_SANITY_DATASET="production"

Create a development dataset for testing:

Terminal window
cd sanity
npx sanity dataset create development

Use in development:

.env.local
PUBLIC_SANITY_DATASET="development"

Create a staging dataset:

Terminal window
npx sanity dataset create staging

Workflow:

development → staging → production
(test) (review) (live)
Terminal window
# Set RSS feed URL
echo 'RSS_FEED_URL="https://yourpodcast.com/feed.xml"' >> .env
# Import episodes
npm run import:episodes

This script:

  • Fetches RSS feed
  • Parses episodes
  • Creates Sanity documents
  • Uploads to production dataset
photos/vitalik-buterin.jpg
# Place photos in public/guests/
# photos/danny-ryan.jpg
npm run upload:photos

Check Project ID matches:

Terminal window
# List your projects
npx sanity projects list
# Output:
# my-podcast (abc123xyz) - You

Copy the Project ID to .env:

Terminal window
PUBLIC_SANITY_PROJECT_ID="abc123xyz"

Create the production dataset:

Terminal window
cd sanity
npx sanity dataset create production

Check you’re in the sanity directory:

Terminal window
cd sanity
npx sanity schema deploy
cd ..

Check your token is valid:

  1. Go to sanity.io/manage
  2. Select your project
  3. API → Tokens
  4. Verify token exists and isn’t expired
  5. Regenerate if needed

Check connection to Sanity:

Terminal window
# Test Sanity connection
npx sanity check