sanity-best-practices

作者: sanity-io

我們要將提供的英文描述翻譯成繁體中文。注意事項:保留產品名稱、協定名稱、URL、數字和技術術語。不要添加聲明、解釋、Markdown、項目符號、鏈接、標籤、前綴或額外評論。只翻譯<text>內的文字,不要包含名稱除非它在源文本中出現。不要包含標籤如「description」、「server name」或「skill name」。 源文本: "Comprehensive best practices and integration guides for Sanity CMS development across frameworks and topics. Covers 10+ framework integrations including Next.js, Nuxt, Astro, Remix, SvelteKit, and Angular with framework-specific patterns and setup guidance Includes topic guides for schema design, GROQ query optimization, Visual Editing, Portable Text, images, TypeGen, localization, and content migrations Provides quick-reference structure for loading only relevant guides based on task type,..." 注意:Sanity CMS 是產品名稱,保留。Next.js, Nuxt, Astro, Remix, SvelteKit

npx skills add https://github.com/sanity-io/agent-toolkit --skill sanity-best-practices

Sanity Best Practices

Comprehensive best practices and integration guides for Sanity development, maintained by Sanity. Use the quick reference below to load only the one or two topic files that match the task.

When to Apply

Reference these guidelines when:

  • Setting up a new Sanity project or onboarding
  • Integrating Sanity with a frontend framework (Next.js, Nuxt, Astro, Remix, SvelteKit, Hydrogen)
  • Writing GROQ queries or optimizing performance
  • Designing content schemas
  • Implementing Visual Editing and live preview
  • Working with images, Portable Text, or page builders
  • Configuring Sanity Studio structure
  • Setting up TypeGen for type safety
  • Implementing localization
  • Migrating content from other systems
  • Building custom apps with the Sanity App SDK
  • Managing infrastructure with Blueprints
  • Automating content workflows with Sanity Functions

Global Rules

  • Let Sanity generate _id values for ordinary documents. Do not create deterministic UUIDs, slug-derived IDs, or legacy-system IDs when creating documents.
  • Model relationships with reference fields, then resolve related documents with GROQ lookups, source-key fields, or returned _id values from created documents.
  • Use explicit document IDs mainly for singleton documents controlled by Studio Structure, including localized singletons such as homePage-en.

Quick Reference

Integration Guides

  • get-started - Interactive onboarding for new Sanity projects
  • nextjs - Next.js App Router, Live Content API, standalone Studio
  • nuxt - Nuxt integration with @nuxtjs/sanity
  • angular - Angular integration with @sanity/client, signals, resource API
  • astro - Astro integration with @sanity/astro
  • remix - React Router / Remix integration
  • svelte - SvelteKit integration with @sanity/svelte-loader
  • hydrogen - Shopify Hydrogen with Sanity
  • project-structure - Standalone Studio and monorepo patterns
  • app-sdk - Custom applications with Sanity App SDK
  • blueprints - Infrastructure as Code with Sanity Blueprints
  • functions - Automating content workflows with Sanity Functions

Topic Guides

  • groq - GROQ query patterns, type safety, performance optimization
  • schema - Schema design, field definitions, validation, deprecation patterns
  • visual-editing - Presentation Tool, Stega, overlays, live preview
  • page-builder - Page Builder arrays, block components, live editing
  • portable-text - Rich text rendering and custom components
  • image - Image schema, URL builder, hotspots, LQIP, Next.js Image
  • studio-structure - Desk structure, singletons, navigation
  • typegen - TypeGen configuration, workflow, type utilities
  • seo - Metadata, sitemaps, Open Graph, JSON-LD
  • localization - i18n patterns, document vs field-level, locale management
  • migration - Content import overview (see also migration-html-import)
  • migration-html-import - HTML to Portable Text with @portabletext/block-tools

How to Use

Start with the single framework or topic guide that best matches the request, then read additional references only when the task crosses concerns. Use these reference files for detailed explanations and code examples:

references/groq.md
references/schema.md
references/nextjs.md

Each reference file contains:

  • Comprehensive topic or integration coverage
  • Incorrect and correct code examples
  • Decision matrices and workflow guidance
  • Framework-specific patterns where applicable

來自 sanity-io 的更多技能

sanity-migration
sanity-io
規劃、執行並審查從其他內容管理系統及內容平台遷移至 Sanity 的作業。適用於從 AEM、Adobe Experience Manager、Contentful、Strapi、Webflow、WordPress、Payload、Drupal、Markdown/MDX/frontmatter 檔案、WXR/XML 匯出、CMS API、資料庫匯出、靜態 HTML 進行遷移或平台轉換,或設計資料擷取、轉換、Portable Text 轉換、資產遷移、重新導向、驗證及切換流程時使用。
officialdevelopmentdatabase
create-agent-with-sanity-context
sanity-io
透過 Agent Context 建立對 Sanity 內容有結構化存取權限的 AI 代理。適用於設定由 Sanity 驅動的聊天機器人、將 AI 助手連接到 Sanity…
official
dial-your-context
sanity-io
互動式工作階段,用於為 Sanity Agent Context MCP 建立「指令」欄位內容。每當使用者提及調整代理上下文、改善…時,請使用此技能。
official
optimize-agent-prompt
sanity-io
透過引導式對話調整您的 Sanity Agent Context 代理。將探索數據轉換為可投入生產的指令,並精心設計系統提示…
official
shape-your-agent
sanity-io
互動式工作階段,用於為由 Sanity Agent Context MCP 驅動的 AI 代理設計系統提示。當使用者想要定義代理人格時,請使用此技能…
official
content-experimentation-best-practices
sanity-io
結構化指引,涵蓋設計、執行與分析內容實驗以提升轉換率與參與度。內容包括假設框架、指標選擇、樣本數計算,以及A/B測試與多變量實驗中的統計顯著性檢定。提供關於p值、信賴區間、統計檢定力分析及貝氏方法的詳細資源,用於解讀實驗結果。同時包含CMS整合模式,以便在欄位層級管理變體,並連接外部系統。
official
content-modeling-best-practices
sanity-io
結構化內容建模指南,涵蓋綱要設計、可重用性與多渠道發布。核心原則包括:將內容視為數據而非頁面、維護單一事實來源、為未來渠道設計,以及優化編輯工作流程。提供關於引用與嵌入物件、關注點分離及內容重用模式的決策框架。包含針對扁平、階層與分面分類法的分類學指引。適用於...
official
portable-text-conversion
sanity-io
將 HTML 和 Markdown 內容轉換為適用於 Sanity 的可攜式文字區塊。用於從舊版 CMS 遷移內容、將 HTML 或 Markdown 匯入 Sanity 等情境。
official