Sitemap

How to add a table in Sanity

2 min readJun 3, 2025

--

Step 1: Create the Schema File

Create a new file in sanity/schemaTypes/ (e.g., sanity/schemaTypes/blogType.ts):

typescript
import {defineArrayMember, defineField, defineType} from 'sanity'

export const blogType = defineType({
name: 'blog',
title: 'Blog Posts',
type: 'document',
fields: [
defineField({
name: 'title',
title: 'Title',
type: 'string'
}),
defineField({
name: 'content',
title: 'Content',
type: 'array',
of: [
defineArrayMember({
type: 'block'
})
]
}),
// Add more fields as needed
]
})

Step 2: Add to Schema Index

In sanity/schemaTypes/index.ts, add your import and include it in the types array:

typescript
import { type SchemaTypeDefinition } from 'sanity'

import {blockContentType} from './blockContentType'
import {artistType} from './artistType'
import {artworkType} from './artworkType'
import {showType} from './showType'
import {venueType} from './venueType'
import {collectorType} from './collectorType'
import {saleType} from './saleType'
import {curatorType} from './curatorType'
import {categoryType} from './categoryType'
import {aboutType} from './aboutType'
import {blogType} from './blogType' // Add this import
export const schema: { types: SchemaTypeDefinition[] } = {
types: [
blockContentType,
artistType,
artworkType,
showType,
venueType,
collectorType,
saleType,
curatorType,
categoryType,
aboutType,
blogType, // Add this to the array
],
}

Step 3: Add to Structure (Navigation)

In sanity/structure.ts, add your new document type:

typescript
export const structure: StructureResolver = (S: StructureBuilder) =>
S.list()
.title('Content')
.items([
S.documentTypeListItem('artist').title('Artists'),
S.documentTypeListItem('artwork').title('Artworks'),
S.documentTypeListItem('show').title('Shows'),
S.documentTypeListItem('venue').title('Venues'),
S.documentTypeListItem('collector').title('Collectors'),
S.documentTypeListItem('sale').title('Sales'),
S.documentTypeListItem('curator').title('Curators'),
S.documentTypeListItem('category').title('Categories'),
S.documentTypeListItem('about').title('About Page'),
S.documentTypeListItem('blog').title('Blog Posts'), // Add this line
S.divider(),
...S.documentTypeListItems().filter((item: ReturnType<typeof S.documentTypeListItems>[number]) => {
const id = item.getId()
return typeof id === 'string' && ![
'artist',
'artwork',
'show',
'venue',
'collector',
'sale',
'curator',
'category',
'about',
'blog', // Add this to the filter
].includes(id)
}),
])

Step 4: Deploy/Restart

# If running locally
npm run dev

# If deploying to hosted studio
git add . && git commit -m "message" && git push origin main
sanity deploy

Step 5: Verify

  1. Open your Sanity Studio
  2. Look for “Blog Posts” (or whatever you named it) in the sidebar
  3. Create a test entry to confirm it works

--

--

No responses yet