seofields
docs

Quick Start

Get SEO fields running in your Sanity Studio in under 2 minutes.

1. Add the Plugin

sanity.config.ts
import { defineConfig } from 'sanity'
import seofields from 'sanity-plugin-seofields'

export default defineConfig({
  name: 'your-project',
  title: 'Your Project',
  projectId: 'your-project-id',
  dataset: 'production',
  plugins: [
    seofields(),  // Zero-config setup
  ],
  schema: {
    types: [/* your schemas */],
  },
})

2. Add SEO Fields to Documents

Add the seoFields type to any document schema:

schemas/page.ts
import { defineField, defineType } from 'sanity'

export default defineType({
  name: 'page',
  title: 'Page',
  type: 'document',
  fields: [
    defineField({
      name: 'title',
      title: 'Title',
      type: 'string',
    }),
    defineField({
      name: 'slug',
      title: 'Slug',
      type: 'slug',
      options: { source: 'title' },
    }),
    defineField({
      name: 'content',
      title: 'Content',
      type: 'text',
    }),
    // Add the complete SEO package
    defineField({
      name: 'seo',
      title: 'SEO',
      type: 'seoFields',
    }),
  ],
})

3. Use Individual Components

Or pick only the components you need:

schemas/article.ts
import { defineField, defineType } from 'sanity'

export default defineType({
  name: 'article',
  title: 'Article',
  type: 'document',
  fields: [
    // ... other fields

    defineField({
      name: 'openGraph',
      title: 'Open Graph',
      type: 'openGraph',
    }),
    defineField({
      name: 'twitterCard',
      title: 'X (Twitter) Card',
      type: 'twitter',
    }),
    defineField({
      name: 'metaAttributes',
      title: 'Custom Meta Tags',
      type: 'metaTag',
    }),
  ],
})

4. Check the Dashboard

Open your Sanity Studio — the SEO Health tab appears automatically in the navigation. It scans all documents with an seo field and displays completeness scores, issues, and direct links to each document.

What's included out of the box: Meta title & description with character counters, Open Graph tags, X Card tags, robots directives, keyword management, custom meta attributes, image management, live SERP preview, and the SEO Health Dashboard.