sanity-plugin-seofields
v1.6.5
Published
The only Sanity Studio SEO plugin with a built-in audit dashboard. Manage meta tags, Open Graph, Twitter Cards, robots directives, JSON-LD structured data, and 38 Schema.org types.
Maintainers
Readme
sanity-plugin-seofields
The only Sanity SEO plugin with a built-in audit dashboard.
Manage meta tags, Open Graph, Twitter Cards, robots directives, and 38 Schema.org/JSON-LD types — all inside Sanity Studio v3/v4/v5.
⭐ If this plugin saves you time, please leave a rating on the Sanity Plugin Directory, star it on GitHub, and leave a review on the docs site. It helps other developers find it.
Installation
npm install sanity-plugin-seofieldsQuick Start
1. Register the plugin
// sanity.config.ts
import {defineConfig} from 'sanity'
import seofields from 'sanity-plugin-seofields'
export default defineConfig({
plugins: [seofields()],
})2. Add SEO fields to a document
import {defineField, defineType} from 'sanity'
export default defineType({
name: 'page',
type: 'document',
fields: [
defineField({name: 'title', type: 'string'}),
defineField({name: 'seo', type: 'seoFields'}),
],
})That's it. The seoFields type is automatically registered by the plugin.
Available Schema Types
| Type | Description |
| --------------- | ------------------------------------ |
| seoFields | Complete SEO bundle (recommended) |
| openGraph | Open Graph tags for social sharing |
| twitter | X (Twitter) Card settings |
| metaTag | Container for custom meta attributes |
| metaAttribute | Single key/value meta attribute |
| robots | noindex / nofollow directives |
Configuration
seofields({
seoPreview: true,
fieldOverrides: {
title: {title: 'Page Title'},
},
defaultHiddenFields: ['openGraphSiteName', 'twitterSite'],
fieldVisibility: {
post: {hiddenFields: ['twitterSite']},
},
})| Option | Type | Default | Description |
| --------------------- | --------- | ------- | --------------------------------------- |
| seoPreview | boolean | true | Enable/disable live SEO preview |
| fieldOverrides | object | {} | Customize field titles and descriptions |
| defaultHiddenFields | array | [] | Hide sitewide fields globally |
| fieldVisibility | object | {} | Hide fields per document type |
→ Full configuration reference
SEO Health Dashboard
This is the feature that sets this plugin apart from every other Sanity SEO plugin.
A built-in Studio tool that audits SEO completeness across all your documents at once — scores each document, highlights missing fields, and links directly to what needs fixing. No external tools. No leaving Studio.
Requires a free license key — get yours here.
seofields({
dashboard: {
enabled: true,
licenseKey: process.env.SANITY_STUDIO_SEO_LICENSE_KEY,
},
})Schema.org / JSON-LD
The plugin ships 38 Schema.org types as Sanity schema definitions + React components that render <script type="application/ld+json"> tags.
1. Register schema types in Studio
// sanity.config.ts
import {schemaOrg} from 'sanity-plugin-seofields/schema'
export default defineConfig({
plugins: [seofields(), schemaOrg()], // all 38 types at once
})Or register only what you need:
import {schemaOrgArticlePlugin, schemaOrgOrganizationPlugin} from 'sanity-plugin-seofields/schema'
export default defineConfig({
plugins: [seofields(), schemaOrgArticlePlugin(), schemaOrgOrganizationPlugin()],
})2. Add to a document schema
defineField({name: 'schemaOrg', type: 'schemaOrg'}) // combined array field
// or individual types:
defineField({name: 'article', type: 'schemaOrgArticle'})3. Render in Next.js
// Combined renderer
import {SchemaOrgScripts} from 'sanity-plugin-seofields/schema/next'
export default function Layout({data}) {
return <SchemaOrgScripts items={data.schemaOrg} />
}
// Or individual components
import {ArticleSchema, OrganizationSchema} from 'sanity-plugin-seofields/schema/next'
export default function Page({data}) {
return (
<>
<ArticleSchema data={data.article} />
<OrganizationSchema data={data.org} />
</>
)
}All 38 available types: AggregateRating, Article, BlogPosting, Book, Brand, BreadcrumbList, ContactPoint, Country, Course, Event, FAQPage, HowTo, ImageObject, ItemList, JobPosting, LegalService, LocalBusiness, Movie, MusicAlbum, MusicRecording, NewsArticle, Offer, Organization, Person, Place, PostalAddress, Product, ProfilePage, Recipe, Restaurant, Review, Service, SocialMediaPosting, SoftwareApplication, VideoObject, WebApplication, WebPage, Website.
Next.js Integration
import {buildSeoMeta, SeoMetaTags} from 'sanity-plugin-seofields/next'CLI
npx seofields→ CLI docs
Links
- 📖 Documentation
- 🐛 Issues
- 📦 npm
- 📝 Changelog
Contributing
PRs and issues are welcome. See CONTRIBUTING.md.
