Skip to main content
seofields
docs

seofields CLI

The seofields CLI is a developer toolkit bundled with the plugin. Manage SEO configuration, audit content health, and export data — all from your terminal.

Terminal — seofields

Quick Start

bash
# Add seofields() to your sanity.config
npx seofields init

# Create a CLI config file (stores credentials)
npx seofields create-config

# Run an SEO health report
npx seofields report

# Check your setup
npx seofields doctor

Commands

init

Add seofields() plugin to your sanity.config file

npx seofields init [--schema-org]

config

Update seofields() configuration options from the terminal

npx seofields config --baseUrl=https://example.com

create-config

Interactive wizard to create a seofields.cli.ts config file

npx seofields create-config

report

Generate an SEO health report for all documents

npx seofields report [--format table|summary]

export

Export all documents with SEO fields as JSON or CSV

npx seofields export --format csv --output audit.csv

doctor

Check plugin configuration, dependencies, and setup

npx seofields doctor

CLI Config File

Instead of passing --project-id, --dataset, and --token on every command, create a seofields.cli.ts file in your project root:

seofields.cli.ts
// seofields.cli.ts
import { defineSeoCli } from "sanity-plugin-seofields/define-cli";

export default defineSeoCli({
  projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID!,
  dataset: process.env.NEXT_PUBLIC_SANITY_DATASET!,
  token: process.env.SANITY_READ_TOKEN,
});

💡 Pro Tip

The CLI automatically loads .env, .env.local, and .env.development.local files. Use process.env.VAR_NAME in your config file and it will resolve at runtime.

Was this page helpful?