🗓️ Everything *[NYC] is back. A free gathering for AI builders. Sept 9

Sanity SEO Fields Plugin

The Sanity SEO Fields Plugin makes SEO simple and accessible, helping teams and creators implement web-standard, social-ready content with ease. It bridges complex SEO needs and content creation, boosting visibility, engagement, and best-practice adoption across the community.

By Desai Hardik

Install command

npm i sanity-plugin-seofields

sanity-plugin-seofields — SEO fields for Sanity Studio

sanity-plugin-seofields

SEO fields, social metadata, Schema.org JSON-LD, AI generation, and SEO health checks for Sanity Studio.

npm version npm downloads license GitHub stars Sanity

Documentation · Quick start · Configuration · AI · Schema.org · CLI


Features

  • Complete seoFields object type for title, description, canonical URL, keywords, meta image, robots, Open Graph, X/Twitter, hreflang, and custom meta tags
  • Live SEO preview inside Sanity Studio
  • Optional SEO Health Dashboard for document audits and CSV/JSON exports
  • AI-assisted SEO copy generation with server-side proxy helpers
  • Schema.org JSON-LD schema types and React/Next.js render helpers
  • Framework-neutral head helpers for Next.js, Astro, Nuxt, Vue, SvelteKit, Remix, and custom renderers
  • CLI for setup, diagnostics, reports, and exports

Installation

npm install sanity-plugin-seofields

Peer dependencies:

sanity   ^3 || ^4 || ^5
react    ^18 || ^19

Quick Start

Register the plugin in sanity.config.ts:

import {defineConfig} from 'sanity'
import seofields from 'sanity-plugin-seofields'

export default defineConfig({
  // ...
  plugins: [seofields()],
})

Add SEO fields to a document schema:

import {defineField, defineType} from 'sanity'

export default defineType({
  name: 'page',
  title: 'Page',
  type: 'document',
  fields: [
    defineField({
      name: 'title',
      type: 'string',
    }),
    defineField({
      name: 'seo',
      title: 'SEO',
      type: 'seoFields',
    }),
  ],
})

Render SEO metadata in Next.js:

import type {Metadata} from 'next'
import {buildSeoMeta} from 'sanity-plugin-seofields/next'

export async function generateMetadata(): Promise<Metadata> {
  const page = await getPage()

  return buildSeoMeta({
    seo: page.seo,
    baseUrl: 'https://example.com',
    path: `/${page.slug}`,
    defaults: {
      title: page.title,
      description: 'Default site description',
    },
  })
}

For Astro, Nuxt, Vue, SvelteKit, Remix, or custom renderers, use buildSeoHead() from sanity-plugin-seofields/head.

Full guide: Frontend integration

TopicLink
Quick startDocs
Plugin configurationDocs
Frontend integrationDocs
AI content generationDocs
SEO Health DashboardDocs
Schema.org structured dataDocs
CLIDocs
License keyGet license

Package Exports

Import pathUse
sanity-plugin-seofieldsStudio plugin, schema types, dashboard helpers, shared types
sanity-plugin-seofields/headFramework-neutral SEO helpers
sanity-plugin-seofields/serverServer-side AI proxy adapters
sanity-plugin-seofields/nextNext.js metadata helpers and React meta tags
sanity-plugin-seofields/schemaSchema.org Sanity schema plugins
sanity-plugin-seofields/schema/nextSchema.org React JSON-LD components
sanity-plugin-seofields/define-cliCLI configuration helper

CLI

npx seofields

Docs: CLI guide

Compatibility

RuntimeSupported
Node.js>=18
Sanity Studio^3, ^4, ^5
React^18, ^19
Module formatESM and CommonJS
TypeScriptIncluded

Contributing

License

MIT © Hardik Desai

Related contributions