Feature
Sanity meta tags that editors can actually maintain
Use sanity-plugin-seofields to add structured SEO fields to Sanity documents: meta title, description, canonical URL, keywords, robots controls, images, previews, and custom meta attributes.
Benefits
Clean editor inputs
Editors work in labeled Sanity fields instead of asking developers to update page head markup.
Search-ready fields
Store title, description, canonical URL, keywords, robots directives, and images in one reusable object.
Preview before publish
Live previews and validation messages make missing or overlong metadata visible while content is being edited.
How it works in Sanity
Register the plugin
Add seofields() to sanity.config.ts so Sanity knows about seoFields and related object types.
Add seoFields
Place a field named seo on each document type that needs page-level metadata.
Render in your frontend
Query seo fields with GROQ and pass them to Next.js helpers or framework-neutral head helpers.
Code examples
import { defineField, defineType } from 'sanity'
export default defineType({
name: 'page',
title: 'Page',
type: 'document',
fields: [
defineField({ name: 'title', type: 'string' }),
defineField({
name: 'slug',
type: 'slug',
options: { source: 'title' },
}),
defineField({
name: 'seo',
title: 'SEO',
type: 'seoFields',
}),
],
})*[_type == "page" && slug.current == $slug][0]{
title,
"slug": slug.current,
seo {
title,
description,
canonicalUrl,
keywords,
metaImage { asset-> { url } },
robots { noIndex, noFollow, noArchive }
}
}import { buildSeoHead } from 'sanity-plugin-seofields/head'
const head = buildSeoHead({
seo: page.seo,
baseUrl: 'https://example.com',
path: `/${page.slug}`,
})
// head.title, head.meta, and head.link can be mapped into Astro, Nuxt,
// Vue, SvelteKit, Remix, or a custom renderer.Related docs
FAQ
What meta fields does seoFields include?
The main seoFields object includes title, description, meta image, keywords, canonical URL, robots settings, hreflang entries, Open Graph, X Cards, and preview fields.
Can I use a smaller schema than seoFields?
Yes. Use baseMeta when you only want title, description, image, keywords, canonical URL, and custom meta attributes.
Do editors need to know HTML meta tag syntax?
No. Editors fill in Sanity fields, and your frontend renders the tags through Next.js metadata APIs or framework-native head APIs.
Does the plugin create a sitemap?
No. Sitemap generation belongs in your frontend, but the stored SEO fields can be queried and used by your sitemap code.
Add editable metadata to Sanity
Start with the schema docs, then wire the queried fields into your frontend metadata layer.