seofields
docs

Field Visibility

Control which SEO fields are visible on different document types. Perfect for managing sitewide settings in a dedicated document.

Per-Document Type

Hide specific fields on different document types:

Per-type visibility
seofields({
  fieldVisibility: {
    page: {
      hiddenFields: ['openGraphSiteName', 'twitterSite', 'keywords'],
    },
    post: {
      hiddenFields: ['openGraphSiteName', 'metaAttributes'],
    },
    product: {
      hiddenFields: ['canonicalUrl', 'robots'],
    },
  },
})

Global Hidden Fields

Hide fields across all document types at once:

Global hidden fields
seofields({
  defaultHiddenFields: ['openGraphSiteName', 'twitterSite', 'keywords'],
})

Site Settings Integration

A common pattern is to manage sitewide fields (like site name and X handle) in a dedicated Site Settings document, then hide those fields from individual pages:

schemas/siteSettings.ts
// schemas/siteSettings.ts
export default defineType({
  name: 'siteSettings',
  title: 'Site Settings',
  type: 'document',
  fields: [
    defineField({
      name: 'openGraphSiteName',
      title: 'Open Graph Site Name',
      type: 'string',
    }),
    defineField({
      name: 'twitterSite',
      title: 'X (Twitter) Site Handle',
      type: 'string',
    }),
  ],
})
sanity.config.ts
// sanity.config.ts — hide sitewide fields from pages
seofields({
  fieldVisibility: {
    page: {
      hiddenFields: ['openGraphSiteName', 'twitterSite'],
    },
    post: {
      hiddenFields: ['openGraphSiteName', 'twitterSite'],
    },
  },
})

Use Cases

Sitewide Settings

Manage site name and X handle in a dedicated document, hide from individual pages.

Simplified Editing

Hide advanced fields (custom meta, robots) from content editors who don't need them.

Content Type Workflows

Different content types need different SEO fields — products don't need canonical URLs, blog posts don't need custom meta.

Note: Hiding openGraphImage or twitterImage automatically hides their imageType and imageUrl variants too — keeping the editor clean and consistent.