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.
Quick Start
# 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 doctorCommands
init
Add seofields() plugin to your sanity.config file
config
Update seofields() configuration options from the terminal
create-config
Interactive wizard to create a seofields.cli.ts config file
report
Generate an SEO health report for all documents
export
Export all documents with SEO fields as JSON or CSV
doctor
Check plugin configuration, dependencies, and setup
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
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?