sveltia-cms

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Sveltia CMS Skill

Sveltia CMS 集成指南

Complete skill for integrating Sveltia CMS into static site projects.

将Sveltia CMS集成到静态站点项目的完整指南。

Current Versions

当前版本

  • @sveltia/cms: 0.128.5 (verified January 2026)
  • Status: Public Beta (v1.0 expected early 2026)
  • Maturity: Production-ready (270+ issues solved from predecessor)

  • @sveltia/cms: 0.128.5(2026年1月验证)
  • 状态: 公开测试版(预计2026年初发布v1.0)
  • 成熟度: 可用于生产环境(已修复前身产品的270+个问题)

When to Use This Skill

适用场景

✅ Use Sveltia CMS When:

✅ 推荐使用Sveltia CMS的场景:

  • Git-based workflow desired (content as Markdown/YAML/TOML/JSON in repository)
  • Lightweight solution required (<500 KB vs 1.5-2.6 MB for competitors)
  • Migrating from Decap/Netlify CMS (drop-in replacement, change 1 line)
  • Non-technical editors need access without Git knowledge
  • 希望采用Git工作流(内容以Markdown/YAML/TOML/JSON格式存储在代码仓库中)
  • 需要轻量级解决方案(包体积<500KB,竞品为1.5-2.6MB)
  • 从Decap/Netlify CMS迁移(直接替换,仅需修改1行代码)
  • 非技术编辑人员需要无需Git知识即可访问的内容编辑入口

❌ Don't Use Sveltia CMS When:

❌ 不推荐使用Sveltia CMS的场景:

  • Real-time collaboration needed (multiple users editing simultaneously) - Use Sanity, Contentful, or TinaCMS instead
  • Visual page building required (drag-and-drop) - Use Webflow, Builder.io instead
  • React-specific visual editing needed - Use TinaCMS instead

  • 需要实时协作(多用户同时编辑)——推荐使用Sanity、Contentful或TinaCMS
  • 需要可视化页面搭建(拖拽式)——推荐使用Webflow、Builder.io
  • 需要React专属的可视化编辑功能——推荐使用TinaCMS

Breaking Changes & Updates (v0.105.0+)

重大变更与更新(v0.105.0+)

v0.127.0 (December 29, 2025) - slug_length Deprecation

v0.127.0(2025年12月29日)- slug_length 已弃用

DEPRECATION: The
slug_length
collection option is deprecated and will be removed in v1.0.
Migration:
yaml
undefined
弃用通知
slug_length
集合选项已被弃用,将在v1.0版本中移除。
迁移方案
yaml
undefined

❌ Deprecated (pre-v0.127.0)

❌ 已弃用(v0.127.0之前版本)

collections:
  • name: posts slug_length: 50
collections:
  • name: posts slug_length: 50

✅ New (v0.127.0+)

✅ 新写法(v0.127.0+)

slug: maxlength: 50

**Timeline**: Will be removed in Sveltia CMS 1.0 (expected early 2026).

**Source**: [Release v0.127.0](https://github.com/sveltia/sveltia-cms/releases/tag/v0.127.0)

---
slug: maxlength: 50

**时间线**:将在Sveltia CMS 1.0版本(预计2026年初)中移除。

**来源**:[Release v0.127.0](https://github.com/sveltia/sveltia-cms/releases/tag/v0.127.0)

---

v0.120.0 (November 24, 2025) - Author Template Tags

v0.120.0(2025年11月24日)- 作者模板标签

New Feature: Hidden widget now supports author template tags:
  • {{author-email}}
    - Signed-in user's email
  • {{author-login}}
    - Signed-in user's login name
  • {{author-name}}
    - Signed-in user's display name
Usage:
yaml
fields:
  - label: Author Email
    name: author_email
    widget: hidden
    default: '{{author-email}}'
Commit message templates also support
{{author-email}}
tag.

新功能:隐藏小部件现在支持作者模板标签:
  • {{author-email}}
    - 登录用户的邮箱
  • {{author-login}}
    - 登录用户的用户名
  • {{author-name}}
    - 登录用户的显示名称
使用示例
yaml
fields:
  - label: Author Email
    name: author_email
    widget: hidden
    default: '{{author-email}}'
提交消息模板同样支持
{{author-email}}
标签。

v0.119.0 (November 16, 2025) - TOML Config Support

v0.119.0(2025年11月16日)- TOML配置支持

New Feature: Configuration files can now be written in TOML format (previously YAML-only).
Migration:
toml
undefined
新功能:配置文件现在可以使用TOML格式编写(之前仅支持YAML)。
迁移方案
toml
undefined

admin/config.toml (NEW)

admin/config.toml(新写法)

[backend] name = "github" repo = "owner/repo" branch = "main"
media_folder = "static/images/uploads" public_folder = "/images/uploads"

**Recommendation**: YAML is still preferred for better tooling support.

---
[backend] name = "github" repo = "owner/repo" branch = "main"
media_folder = "static/images/uploads" public_folder = "/images/uploads"

**推荐**:仍优先使用YAML格式,因为其工具支持更完善。

---

v0.118.0 (November 15, 2025) - TypeScript Breaking Change

v0.118.0(2025年11月15日)- TypeScript重大变更

BREAKING: Renamed
SiteConfig
export to
CmsConfig
for compatibility with Netlify/Decap CMS.
Migration:
typescript
// ❌ Old (v0.117.x)
import type { SiteConfig } from '@sveltia/cms';

// ✅ New (v0.118.0+)
import type { CmsConfig } from '@sveltia/cms';

const config: CmsConfig = {
  backend: { name: 'github', repo: 'owner/repo' },
  collections: [/* ... */],
};
Impact: TypeScript users only. Breaking change for type imports.

重大变更:为了与Netlify/Decap CMS兼容,
SiteConfig
导出已重命名为
CmsConfig
迁移方案
typescript
// ❌ 旧写法(v0.117.x)
import type { SiteConfig } from '@sveltia/cms';

// ✅ 新写法(v0.118.0+)
import type { CmsConfig } from '@sveltia/cms';

const config: CmsConfig = {
  backend: { name: 'github', repo: 'owner/repo' },
  collections: [/* ... */],
};
影响范围:仅TypeScript用户。对类型导入造成重大变更。

v0.117.0 (November 14, 2025) - Enhanced Validation

v0.117.0(2025年11月14日)- 增强验证

New Features:
  • Exported
    CmsConfig
    type for direct TypeScript import
  • Enhanced config validation for collection names, field types, and relation references
  • Better error messages for invalid configurations

新功能
  • 导出
    CmsConfig
    类型,支持直接在TypeScript中导入
  • 增强对集合名称、字段类型和关联引用的配置验证
  • 针对无效配置提供更清晰的错误提示

v0.115.0 (November 5, 2025) - Field-Specific Media Folders

v0.115.0(2025年11月5日)- 字段级媒体文件夹

New Feature: Override
media_folder
at the field level (not just collection level).
Usage:
yaml
collections:
  - name: posts
    label: Blog Posts
    folder: content/posts
    media_folder: static/images/posts  # Collection-level default
    fields:
      - label: Featured Image
        name: image
        widget: image
        media_folder: static/images/featured  # ← Field-level override
        public_folder: /images/featured

      - label: Author Avatar
        name: avatar
        widget: image
        media_folder: static/images/avatars  # ← Another override
        public_folder: /images/avatars
Use case: Different media folders for different image types in same collection.

新功能:可以在字段级别覆盖
media_folder
配置(之前仅支持集合级别)。
使用示例
yaml
collections:
  - name: posts
    label: Blog Posts
    folder: content/posts
    media_folder: static/images/posts  # 集合级默认配置
    fields:
      - label: Featured Image
        name: image
        widget: image
        media_folder: static/images/featured  # ← 字段级覆盖配置
        public_folder: /images/featured

      - label: Author Avatar
        name: avatar
        widget: image
        media_folder: static/images/avatars  # ← 另一项覆盖配置
        public_folder: /images/avatars
适用场景:同一集合中不同类型图片需要存储到不同文件夹的情况。

v0.113.5 (October 27, 2025) - Logo Deprecation

v0.113.5(2025年10月27日)- Logo配置已弃用

DEPRECATION:
logo_url
option is now deprecated. Migrate to
logo.src
.
Migration:
yaml
undefined
弃用通知
logo_url
选项已被弃用,请迁移到
logo.src
迁移方案
yaml
undefined

❌ Deprecated

❌ 已弃用

✅ New (v0.113.5+)

✅ 新写法(v0.113.5+)

v0.105.0 (September 15, 2024) - Security Breaking Change

v0.105.0(2024年9月15日)- 安全重大变更

BREAKING:
sanitize_preview
default changed to
true
for Markdown widget (XSS prevention).
Impact:
  • Before v0.105.0:
    sanitize_preview: false
    (compatibility with Netlify/Decap CMS, but vulnerable to XSS)
  • After v0.105.0:
    sanitize_preview: true
    (secure by default)
Migration:
yaml
collections:
  - name: posts
    fields:
      - label: Body
        name: body
        widget: markdown
        sanitize_preview: false  # ← Add ONLY if you trust all CMS users
Recommendation: Keep default (
true
) unless disabling fixes broken preview AND you fully trust all CMS users.

重大变更:Markdown小部件的
sanitize_preview
默认值已改为
true
(用于防止XSS攻击)。
影响
  • v0.105.0之前
    sanitize_preview: false
    (与Netlify/Decap CMS兼容,但存在XSS漏洞)
  • v0.105.0之后
    sanitize_preview: true
    (默认安全)
迁移方案
yaml
collections:
  - name: posts
    fields:
      - label: Body
        name: body
        widget: markdown
        sanitize_preview: false  # ← 仅当你信任所有CMS用户时才添加此项
推荐:保持默认值
true
,除非禁用后才能修复预览问题且你完全信任所有CMS用户。

Configuration Options

配置选项

Global Slug Options (v0.128.0+)

全局Slug选项(v0.128.0+)

Configure slug generation behavior globally:
yaml
slug:
  encoding: unicode-normalized
  clean_accents: false
  sanitize_replacement: '-'
  lowercase: true   # Default: convert to lowercase (v0.128.0+)
  maxlength: 50     # Default: unlimited (v0.127.0+)
lowercase (v0.128.0+): Set to
false
to preserve original casing in slugs (e.g., "MyBlogPost" instead of "myblogpost").
Use case: Mixed-case URLs or file names where case matters.

全局配置Slug生成行为:
yaml
slug:
  encoding: unicode-normalized
  clean_accents: false
  sanitize_replacement: '-'
  lowercase: true   # 默认:转换为小写(v0.128.0+)
  maxlength: 50     # 默认:无限制(v0.127.0+)
lowercase(v0.128.0+):设置为
false
可保留Slug的原始大小写(例如保留"MyBlogPost"而非转换为"myblogpost")。
适用场景:URL或文件名对大小写敏感的混合大小写场景。

Raw Format for Text Files (v0.126.0+)

文本文件原始格式(v0.126.0+)

New
raw
format allows editing files without front matter (CSV, JSON, YAML, plain text). Must have single
body
field with widget type:
code
,
markdown
,
richtext
, or
text
.
Use Cases:
  • Edit configuration files (JSON, YAML)
  • Manage CSV data
  • Edit plain text files
Configuration:
yaml
collections:
  - name: config
    label: Configuration Files
    files:
      - label: Site Config
        name: site_config
        file: config.json
        format: raw  # ← NEW format type
        fields:
          - label: Config
            name: body
            widget: code
            default_language: json
Restrictions:
  • Only one field allowed (must be named
    body
    )
  • Widget must be:
    code
    ,
    markdown
    ,
    richtext
    , or
    text
  • No front matter parsing

新增的
raw
格式允许编辑无前置元数据的文件(CSV、JSON、YAML、纯文本)。必须包含单个名为
body
的字段,且小部件类型为
code
markdown
richtext
text
适用场景
  • 编辑配置文件(JSON、YAML)
  • 管理CSV数据
  • 编辑纯文本文件
配置示例
yaml
collections:
  - name: config
    label: Configuration Files
    files:
      - label: Site Config
        name: site_config
        file: config.json
        format: raw  # ← 新增格式类型
        fields:
          - label: Config
            name: body
            widget: code
            default_language: json
限制
  • 仅允许一个字段(必须命名为
    body
  • 小部件类型必须为:
    code
    markdown
    richtext
    text
  • 不解析前置元数据

Number Field String Encoding (v0.125.0+)

数字字段字符串编码(v0.125.0+)

New
value_type
option for Number field accepts
int/string
and
float/string
to save numbers as strings instead of numbers in front matter.
Use Case: Some static site generators or schemas require numeric values stored as strings (e.g.,
age: "25"
instead of
age: 25
).
Configuration:
yaml
fields:
  - label: Age
    name: age
    widget: number
    value_type: int/string  # Saves as "25" not 25

  - label: Price
    name: price
    widget: number
    value_type: float/string  # Saves as "19.99" not 19.99

数字字段新增
value_type
选项,支持
int/string
float/string
,可将数字以字符串形式存储在前置元数据中。
适用场景:部分静态站点生成器或模式要求数值以字符串形式存储(例如
age: "25"
而非
age: 25
)。
配置示例
yaml
fields:
  - label: Age
    name: age
    widget: number
    value_type: int/string  # 存储为"25"而非25

  - label: Price
    name: price
    widget: number
    value_type: float/string  # 存储为"19.99"而非19.99

Editor Pane Locale via URL Query (v0.126.0+)

通过URL查询参数设置编辑器语言(v0.126.0+)

Override editor locale via URL query parameter
?_locale=fr
to get edit links for specific locales.
Use Case: Generate direct edit links for translators or content editors for specific languages.
Example:
https://yourdomain.com/admin/#/collections/posts/entries/my-post?_locale=fr

可通过URL查询参数
?_locale=fr
覆盖编辑器语言,生成特定语言的编辑链接。
适用场景:为翻译人员或内容编辑生成特定语言的直接编辑链接。
示例
https://yourdomain.com/admin/#/collections/posts/entries/my-post?_locale=fr

Richtext Field Type Alias (v0.124.0+)

Richtext字段类型别名(v0.124.0+)

Added
richtext
as an alias for
markdown
widget to align with Decap CMS terminology. Both work identically.
Configuration:
yaml
fields:
  - label: Body
    name: body
    widget: richtext  # ← NEW alias for markdown
Future: HTML output support planned for
richtext
field type.

新增
richtext
作为
markdown
小部件的别名,以与Decap CMS术语对齐。两者功能完全相同。
配置示例
yaml
fields:
  - label: Body
    name: body
    widget: richtext  # ← markdown的新增别名
未来规划:计划为
richtext
字段类型添加HTML输出支持。

Setup Pattern (Framework-Agnostic)

通用搭建步骤(无框架绑定)

All frameworks follow the same pattern:
  1. Create admin directory in public/static folder:
    • Hugo:
      static/admin/
    • Jekyll:
      admin/
    • 11ty:
      admin/
      (with passthrough copy)
    • Astro:
      public/admin/
    • Next.js:
      public/admin/
  2. Create admin/index.html:
    html
    <!doctype html>
    <html lang="en">
      <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Content Manager</title>
      </head>
      <body>
        <script src="https://unpkg.com/@sveltia/cms@0.128.5/dist/sveltia-cms.js" type="module"></script>
      </body>
    </html>
  3. Create admin/config.yml:
    yaml
    backend:
      name: github
      repo: owner/repo
      branch: main
      base_url: https://your-worker.workers.dev  # OAuth proxy (required)
    
    media_folder: static/images/uploads  # Framework-specific path
    public_folder: /images/uploads
    
    collections:
      - name: posts
        label: Blog Posts
        folder: content/posts
        create: true
        fields:
          - { label: 'Title', name: 'title', widget: 'string' }
          - { label: 'Date', name: 'date', widget: 'datetime' }
          - { label: 'Body', name: 'body', widget: 'markdown' }
  4. Access admin:
    http://localhost:<port>/admin/
Framework-specific details: See
templates/
directory for complete examples.

所有框架均遵循以下相同步骤
  1. 在public/static目录中创建admin文件夹
    • Hugo:
      static/admin/
    • Jekyll:
      admin/
    • 11ty:
      admin/
      (需配置透传复制)
    • Astro:
      public/admin/
    • Next.js:
      public/admin/
  2. 创建admin/index.html
    html
    <!doctype html>
    <html lang="en">
      <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>内容管理器</title>
      </head>
      <body>
        <script src="https://unpkg.com/@sveltia/cms@0.128.5/dist/sveltia-cms.js" type="module"></script>
      </body>
    </html>
  3. 创建admin/config.yml
    yaml
    backend:
      name: github
      repo: owner/repo
      branch: main
      base_url: https://your-worker.workers.dev  # OAuth代理(必填)
    
    media_folder: static/images/uploads  # 框架特定路径
    public_folder: /images/uploads
    
    collections:
      - name: posts
        label: 博客文章
        folder: content/posts
        create: true
        fields:
          - { label: '标题', name: 'title', widget: 'string' }
          - { label: '日期', name: 'date', widget: 'datetime' }
          - { label: '正文', name: 'body', widget: 'markdown' }
  4. 访问管理后台
    http://localhost:<port>/admin/
框架特定细节:请查看
templates/
目录获取完整示例。

Authentication: Cloudflare Workers OAuth (Recommended)

认证:Cloudflare Workers OAuth(推荐)

Why Cloudflare Workers: Fastest, free tier available, works with any deployment platform.
Steps:
  1. Deploy Worker:
    bash
    git clone https://github.com/sveltia/sveltia-cms-auth
    cd sveltia-cms-auth
    npm install
    npx wrangler deploy
  2. Register OAuth App on GitHub:
  3. Configure Worker Environment Variables:
    bash
    npx wrangler secret put GITHUB_CLIENT_ID
    # Paste your Client ID
    
    npx wrangler secret put GITHUB_CLIENT_SECRET
    # Paste your Client Secret
  4. Update CMS config:
    yaml
    backend:
      name: github
      repo: owner/repo
      branch: main
      base_url: https://your-worker.workers.dev  # ← Add this line
  5. Test authentication:
    • Open
      /admin/
    • Click "Login with GitHub"
    • Should redirect to GitHub → Authorize → Back to CMS
Alternative: Vercel serverless functions - See
templates/vercel-serverless/

为什么选择Cloudflare Workers:速度最快,提供免费套餐,支持任何部署平台。
步骤
  1. 部署Worker
    bash
    git clone https://github.com/sveltia/sveltia-cms-auth
    cd sveltia-cms-auth
    npm install
    npx wrangler deploy
  2. 在GitHub上注册OAuth应用
  3. 配置Worker环境变量
    bash
    npx wrangler secret put GITHUB_CLIENT_ID
    # 粘贴你的Client ID
    
    npx wrangler secret put GITHUB_CLIENT_SECRET
    # 粘贴你的Client Secret
  4. 更新CMS配置
    yaml
    backend:
      name: github
      repo: owner/repo
      branch: main
      base_url: https://your-worker.workers.dev  # ← 添加此行
  5. 测试认证
    • 打开
      /admin/
    • 点击"Login with GitHub"
    • 应跳转到GitHub → 授权 → 返回CMS
替代方案:Vercel无服务器函数 - 请查看
templates/vercel-serverless/

Common Errors & Solutions

常见错误与解决方案

This skill prevents 10 common errors encountered when setting up Sveltia CMS.
本指南可避免搭建Sveltia CMS时遇到的10种常见错误

1. ❌ OAuth Authentication Failures

1. ❌ OAuth认证失败

Error Message:
  • "Error: Failed to authenticate"
  • Redirect to
    https://api.netlify.com/auth
    instead of GitHub login
Symptoms:
  • Login button does nothing
  • Authentication popup closes immediately
Causes:
  • Missing
    base_url
    in backend config
  • Incorrect OAuth proxy URL
  • Wrong GitHub OAuth callback URL
Solution:
Step 1: Verify config.yml has
base_url
:
yaml
backend:
  name: github
  repo: owner/repo
  branch: main
  base_url: https://your-worker.workers.dev  # ← Must be present
Step 2: Check GitHub OAuth App callback:
  • Should be:
    https://your-worker.workers.dev/callback
  • NOT:
    https://yourdomain.com/callback
Step 3: Test Worker directly:
bash
curl https://your-worker.workers.dev/health
错误提示
  • "Error: Failed to authenticate"
  • 重定向到
    https://api.netlify.com/auth
    而非GitHub登录页
症状
  • 登录按钮无响应
  • 认证弹窗立即关闭
原因
  • 后端配置中缺少
    base_url
  • OAuth代理URL不正确
  • GitHub OAuth回调URL错误
解决方案
步骤1:验证config.yml中包含
base_url
yaml
backend:
  name: github
  repo: owner/repo
  branch: main
  base_url: https://your-worker.workers.dev  # ← 必须存在
步骤2:检查GitHub OAuth应用回调URL
  • 正确应为:
    https://your-worker.workers.dev/callback
  • 错误示例:
    https://yourdomain.com/callback
步骤3:直接测试Worker
bash
curl https://your-worker.workers.dev/health

Should return: {"status": "ok"}

应返回:{"status": "ok"}


---

---

2. ❌ TOML Front Matter Errors

2. ❌ TOML前置元数据错误

Error Message:
  • "Parse error: Invalid TOML"
  • Files missing
    +++
    delimiters
Symptoms:
  • New files created by CMS don't parse in Hugo
  • Content appears above body separator
Causes:
  • Sveltia's TOML generation is buggy in beta
  • Mixed TOML/YAML in same collection
Solution:
Use YAML instead of TOML (recommended):
yaml
collections:
  - name: posts
    folder: content/posts
    format: yaml  # or md (Markdown with YAML frontmatter)
    # NOT: format: toml
If you must use TOML:
  1. Manually fix delimiters after CMS saves
  2. Use pre-commit hook to validate TOML
  3. Wait for beta fixes (track GitHub issues)

错误提示
  • "Parse error: Invalid TOML"
  • 文件缺少
    +++
    分隔符
症状
  • CMS创建的新文件无法在Hugo中解析
  • 内容出现在正文分隔符上方
原因
  • 测试版中Sveltia的TOML生成存在Bug
  • 同一集合中混合使用TOML/YAML格式
解决方案
推荐使用YAML替代TOML
yaml
collections:
  - name: posts
    folder: content/posts
    format: yaml  # 或md(带YAML前置元数据的Markdown)
    # 不推荐:format: toml
如果必须使用TOML
  1. CMS保存后手动修复分隔符
  2. 使用pre-commit钩子验证TOML格式
  3. 等待测试版Bug修复(跟踪GitHub issues)

3. ❌ YAML Parse Errors

3. ❌ YAML解析错误

Error Message:
  • "YAML parse error: Invalid YAML"
  • "Error: Duplicate key 'field_name'"
Symptoms:
  • Existing posts won't load in CMS
  • CMS shows empty fields
Causes:
  • Sveltia is stricter than Hugo/Jekyll about YAML formatting
  • Incorrect indentation or smart quotes
Solution:
Step 1: Validate YAML:
bash
pip install yamllint
find content -name "*.md" -exec yamllint {} \;
Step 2: Common fixes:
Problem: Smart quotes
yaml
undefined
错误提示
  • "YAML parse error: Invalid YAML"
  • "Error: Duplicate key 'field_name'"
症状
  • 现有文章无法在CMS中加载
  • CMS显示空字段
原因
  • Sveltia对YAML格式的要求比Hugo/Jekyll更严格
  • 缩进错误或使用了智能引号
解决方案
步骤1:验证YAML格式
bash
pip install yamllint
find content -name "*.md" -exec yamllint {} \;
步骤2:常见修复
问题:使用智能引号
yaml
undefined

❌ Bad - smart quotes from copy-paste

❌ 错误 - 复制粘贴的智能引号

title: "Hello World" # Curly quotes
title: "Hello World" # 弯引号

✅ Good - straight quotes

✅ 正确 - 直引号

title: "Hello World" # Straight quotes

**Step 3: Auto-fix with yamlfmt:**
```bash
go install github.com/google/yamlfmt/cmd/yamlfmt@latest
find content -name "*.md" -exec yamlfmt {} \;

title: "Hello World" # 直引号

**步骤3:使用yamlfmt自动修复**:
```bash
go install github.com/google/yamlfmt/cmd/yamlfmt@latest
find content -name "*.md" -exec yamlfmt {} \;

4. ❌ Content Not Listing in CMS

4. ❌ CMS中未显示内容

Error Message:
  • "No entries found"
  • "Failed to load entries"
Symptoms:
  • Admin loads but shows no content
  • Files exist in repository but CMS doesn't see them
Causes:
  • Format mismatch (config expects TOML, files are YAML)
  • Incorrect folder path
Solution:
Step 1: Verify folder path:
yaml
undefined
错误提示
  • "No entries found"
  • "Failed to load entries"
症状
  • 管理后台加载成功但无内容显示
  • 代码仓库中存在文件但CMS无法识别
原因
  • 格式不匹配(配置期望TOML,但文件为YAML)
  • 文件夹路径错误
解决方案
步骤1:验证文件夹路径
yaml
undefined

Config says:

配置中指定:

collections:
  • name: posts folder: content/posts # Expects files here
collections:
  • name: posts folder: content/posts # 期望文件存放在此处

Check actual location:

检查实际位置:

ls -la content/posts # Files must exist here

**Step 2: Match format to actual files:**
```yaml
ls -la content/posts # 文件必须存在于此

**步骤2:格式与实际文件匹配**:
```yaml

If files are: content/posts/hello.md with YAML frontmatter

如果文件为:content/posts/hello.md 且带YAML前置元数据

collections:
  • name: posts folder: content/posts format: yaml # or md (same as yaml for .md files)

---
collections:
  • name: posts folder: content/posts format: yaml # 或md(对.md文件与yaml等效)

---

5. ❌ "SVELTIA is not defined" Error

5. ❌ "SVELTIA is not defined" 错误

Error Message:
  • Console error:
    Uncaught ReferenceError: SVELTIA is not defined
Symptoms:
  • Admin page shows white screen
Causes:
  • Missing
    type="module"
    attribute
Solution:
Use correct script tag:
html
<!-- ✅ Correct -->
<script src="https://unpkg.com/@sveltia/cms/dist/sveltia-cms.js" type="module"></script>

<!-- ❌ Wrong - missing type="module" -->
<script src="https://unpkg.com/@sveltia/cms/dist/sveltia-cms.js"></script>
Use version pinning (recommended):
html
<script src="https://unpkg.com/@sveltia/cms@0.128.5/dist/sveltia-cms.js" type="module"></script>

错误提示
  • 控制台错误:
    Uncaught ReferenceError: SVELTIA is not defined
症状
  • 管理后台页面显示空白
原因
  • 缺少
    type="module"
    属性
解决方案
使用正确的脚本标签
html
<!-- ✅ 正确 -->
<script src="https://unpkg.com/@sveltia/cms/dist/sveltia-cms.js" type="module"></script>

<!-- ❌ 错误 - 缺少type="module" -->
<script src="https://unpkg.com/@sveltia/cms/dist/sveltia-cms.js"></script>
推荐固定版本
html
<script src="https://unpkg.com/@sveltia/cms@0.128.5/dist/sveltia-cms.js" type="module"></script>

6. ❌ 404 on /admin

6. ❌ /admin 页面404

Error Message:
  • "404 Not Found" when visiting
    /admin/
Symptoms:
  • Works locally but not in production
Causes:
  • Admin directory not in correct location for framework
Solution:
Framework-specific fixes:
Hugo: Files in
static/
are automatically copied
Jekyll: Add to
_config.yml
:
yaml
include:
  - admin
11ty: Add to
.eleventy.js
:
javascript
module.exports = function(eleventyConfig) {
  eleventyConfig.addPassthroughCopy('admin');
};
Astro: Files in
public/
are automatically copied

错误提示
  • 访问
    /admin/
    时显示"404 Not Found"
症状
  • 本地正常但生产环境异常
原因
  • Admin目录未放在框架要求的正确位置
解决方案
框架特定修复
Hugo
static/
目录下的文件会自动复制
Jekyll:在
_config.yml
中添加:
yaml
include:
  - admin
11ty:在
.eleventy.js
中添加:
javascript
module.exports = function(eleventyConfig) {
  eleventyConfig.addPassthroughCopy('admin');
};
Astro
public/
目录下的文件会自动复制

7. ❌ Images Not Uploading (HEIC Format)

7. ❌ 图片无法上传(HEIC格式)

Error Message:
  • "Unsupported file format"
Symptoms:
  • iPhone photos won't upload
Causes:
  • HEIC format not supported by browsers
Solution:
On iPhone:
  • Settings > Camera > Formats > Most Compatible
  • This saves photos as JPEG instead of HEIC
Or enable image optimization:
yaml
media_libraries:
  default:
    config:
      max_file_size: 10485760  # 10 MB
      transformations:
        raster_image:
          format: webp  # Auto-converts to WebP
          quality: 85

错误提示
  • "Unsupported file format"
症状
  • iPhone照片无法上传
原因
  • 浏览器不支持HEIC格式
解决方案
在iPhone上设置
  • 设置 > 相机 > 格式 > 兼容性最佳
  • 这样照片会保存为JPEG而非HEIC
或启用图片优化
yaml
media_libraries:
  default:
    config:
      max_file_size: 10485760  # 10 MB
      transformations:
        raster_image:
          format: webp  # 自动转换为WebP
          quality: 85

8. ❌ Datetime Widget Format Strictness

8. ❌ 日期时间小部件格式严格性问题

Error Message:
  • Silent data loss (no error shown)
  • Date fields show blank in CMS
Symptoms:
  • Posts with existing dates appear blank when editing
  • Saving overwrites dates with blank values
  • Hugo marks posts as "future" and skips building them
Causes:
  • Default datetime widget outputs timestamps WITHOUT timezone suffix
  • When
    format
    is specified, Sveltia becomes strict - existing entries with different formats show as blank
  • Hugo infers UTC when timezone missing, causing timezone issues
⚠️ CRITICAL: Format Strictness Warning (v0.124.1+)
When you specify a
format
option, Sveltia becomes strict:
  • Existing entries with different formats show as blank
  • Saving will overwrite with blank value (SILENT DATA LOSS)
  • No error message shown
Solution:
Option 1: Use picker_utc (Recommended)
yaml
fields:
  - label: Date
    name: date
    widget: datetime
    picker_utc: true  # Most flexible - outputs with timezone
Option 2: Specify format with timezone (RISKY - see warning above)
yaml
fields:
  - label: Date
    name: date
    widget: datetime
    format: "YYYY-MM-DDTHH:mm:ss.SSSZ"  # Only if ALL existing dates match this format
Option 3: Configure Hugo to accept missing timezone
toml
undefined
错误提示
  • 静默数据丢失(无错误提示)
  • CMS中日期字段显示为空
症状
  • 带有现有日期的文章在编辑时日期显示为空
  • 保存后日期会被覆盖为空值
  • Hugo将文章标记为“未来发布”并跳过构建
原因
  • 默认日期时间小部件输出的时间戳不带时区后缀
  • 当指定
    format
    时,Sveltia会变得严格——格式不匹配的现有条目会显示为空
  • 当缺少时区时,Hugo会默认使用UTC,导致时区问题
⚠️ 重要:格式严格性警告(v0.124.1+)
当你指定
format
选项时,Sveltia会变得严格
  • 格式不匹配的现有条目会显示为
  • 保存时会覆盖为空值(静默数据丢失)
  • 无错误提示
解决方案
选项1:使用picker_utc(推荐)
yaml
fields:
  - label: Date
    name: date
    widget: datetime
    picker_utc: true  # 灵活性最高 - 输出带时区的时间戳
选项2:指定带时区的格式(风险高 - 请查看上述警告)
yaml
fields:
  - label: Date
    name: date
    widget: datetime
    format: "YYYY-MM-DDTHH:mm:ss.SSSZ"  # 仅当所有现有日期均匹配此格式时使用
选项3:配置Hugo接受无时区的日期
toml
undefined

config.toml

config.toml

[frontmatter] date = [":default", ":fileModTime"]

**Prevention**:
1. Don't specify `format` if you have mixed date formats
2. Normalize all dates first before adding `format`
3. Use `picker_utc: true` instead (more flexible)

**Source**: [GitHub Issue #565](https://github.com/sveltia/sveltia-cms/issues/565), fixed in v0.126.0 (improved date parser but format strictness remains)

---
[frontmatter] date = [":default", ":fileModTime"]

**预防措施**:
1. 如果存在混合日期格式,请勿指定`format`
2. 在添加`format`之前先统一所有日期格式
3. 优先使用`picker_utc: true`(更灵活)

**来源**:[GitHub Issue #565](https://github.com/sveltia/sveltia-cms/issues/565),已在v0.126.0中修复(改进了日期解析器,但格式严格性仍保留)

---

9. ❌ GDPR Violation: Google Fonts CDN

9. ❌ GDPR违规:Google Fonts CDN

Error Message:
  • No error shown (privacy compliance issue)
Symptoms:
  • Privacy-focused sites blocked from using Sveltia
  • EU public sector cannot adopt
  • GDPR non-compliance
Causes:
  • Sveltia loads Google Fonts and Material Symbols from Google CDN without user consent
  • Google tracks font usage and collects IP addresses
  • Violates EU data protection law
⚠️ Impact: Blocking issue for EU public sector and privacy-focused sites
Solution (Vite Plugin - Recommended):
typescript
// vite.config.ts
import { defineConfig, type Plugin } from 'vite'

function ensureGDPRCompliantFonts(): Plugin {
  const fontsURLRegex = /fonts\.googleapis\.com\/css2/g
  const replacement = 'fonts.bunny.net/css'
  return {
    name: 'gdpr-compliant-fonts',
    enforce: 'post',
    transform(code) {
      if (fontsURLRegex.test(code)) {
        return code.replaceAll(fontsURLRegex, replacement)
      }
    },
  }
}

export default defineConfig({
  plugins: [ensureGDPRCompliantFonts()],
})
Alternative Solutions:
Option 2: Bunny Fonts (1:1 Google Fonts replacement)
Option 3: Self-hosted fonts
  • Use
    @fontsource
    npm packages
  • Bundle fonts with application
  • No external requests
Maintainer Response:
  • Acknowledged issue
  • Plans to add system font option (post-v1.0)
  • Sveltia itself collects no data (fonts are only concern)

错误提示
  • 无错误提示(隐私合规问题)
症状
  • 注重隐私的站点无法使用Sveltia
  • 欧盟公共部门无法采用
  • 违反GDPR规定
原因
  • Sveltia未经用户同意从Google CDN加载Google Fonts和Material Symbols
  • Google会跟踪字体使用情况并收集IP地址
  • 违反欧盟数据保护法
⚠️ 影响:对欧盟公共部门和注重隐私的站点来说是阻塞性问题
解决方案(Vite插件 - 推荐)
typescript
// vite.config.ts
import { defineConfig, type Plugin } from 'vite'

function ensureGDPRCompliantFonts(): Plugin {
  const fontsURLRegex = /fonts\.googleapis\.com\/css2/g
  const replacement = 'fonts.bunny.net/css'
  return {
    name: 'gdpr-compliant-fonts',
    enforce: 'post',
    transform(code) {
      if (fontsURLRegex.test(code)) {
        return code.replaceAll(fontsURLRegex, replacement)
      }
    },
  }
}

export default defineConfig({
  plugins: [ensureGDPRCompliantFonts()],
})
替代方案
选项2:Bunny Fonts(Google Fonts的1:1替代)
选项3:自托管字体
  • 使用
    @fontsource
    npm包
  • 将字体与应用打包
  • 无外部请求
维护者回应
  • 已确认该问题
  • 计划添加系统字体选项(v1.0之后)
  • Sveltia本身不收集任何数据(仅字体存在问题)

10. ❌ CORS / COOP Policy Errors

10. ❌ CORS / COOP策略错误

Error Message:
  • "Authentication Aborted"
  • "Cross-Origin-Opener-Policy blocked"
Symptoms:
  • OAuth popup opens then closes
Causes:
  • Strict
    Cross-Origin-Opener-Policy
    header blocking OAuth
Solution:
Cloudflare Pages (_headers file):
/*
  Cross-Origin-Opener-Policy: same-origin-allow-popups
  # NOT: same-origin (this breaks OAuth)
Netlify (_headers file):
/*
  Cross-Origin-Opener-Policy: same-origin-allow-popups
Vercel (vercel.json):
json
{
  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        {
          "key": "Cross-Origin-Opener-Policy",
          "value": "same-origin-allow-popups"
        }
      ]
    }
  ]
}

错误提示
  • "Authentication Aborted"
  • "Cross-Origin-Opener-Policy blocked"
症状
  • OAuth弹窗打开后立即关闭
原因
  • 严格的
    Cross-Origin-Opener-Policy
    标头阻止了OAuth
解决方案
Cloudflare Pages(_headers文件):
/*
  Cross-Origin-Opener-Policy: same-origin-allow-popups
  # 不推荐:same-origin(会破坏OAuth)
Netlify(_headers文件):
/*
  Cross-Origin-Opener-Policy: same-origin-allow-popups
Vercel(vercel.json):
json
{
  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        {
          "key": "Cross-Origin-Opener-Policy",
          "value": "same-origin-allow-popups"
        }
      ]
    }
  ]
}

Fixed Issues (Historical Reference)

已修复问题(历史参考)

These issues were present in earlier versions but have been fixed. Documented here for reference.
这些问题存在于早期版本中,但已被修复。在此记录以供参考。

✅ Paths with Parentheses Break Entry Loading (Fixed in v0.128.1)

✅ 含括号的路径导致条目加载失败(v0.128.1中修复)

Issue: Sveltia CMS failed to load existing entries when the
path
option contains parentheses
()
. This affected Next.js/Nextra users using route groups like
app/(content)/(writing)/
.
Symptoms (pre-v0.128.1):
  • Creating new entries worked
  • Loading/listing existing entries failed silently
  • CMS showed "No entries found" despite files existing
Example that failed:
yaml
collections:
  - name: pages
    folder: app/(pages)
    path: "{{slug}}/page"  # ← Failed to load existing entries
    extension: mdx
Status: Fixed in v0.128.1 (January 13, 2026)

问题:当
path
选项包含括号
()
时,Sveltia CMS无法加载现有条目。这影响了使用路由组(如
app/(content)/(writing)/
)的Next.js/Nextra用户。
症状(v0.128.1之前):
  • 创建新条目正常
  • 加载/列出现有条目静默失败
  • CMS显示"No entries found"但实际文件存在
失败示例
yaml
collections:
  - name: pages
    folder: app/(pages)
    path: "{{slug}}/page"  # ← 无法加载现有条目
    extension: mdx
状态:已在v0.128.1中修复(2026年1月13日)

✅ Root Folder Collections Break GitHub Backend (Fixed in v0.125.0)

✅ 根文件夹集合导致GitHub后端失败(v0.125.0中修复)

Issue: Collections with
folder: ""
or
folder: "."
or
folder: "/"
failed when creating new entries via GitHub backend. GraphQL query incorrectly constructed path starting with
/
(absolute) instead of relative path.
Symptoms (pre-v0.125.0):
  • Worked locally via browser File API
  • Failed with GitHub backend (GraphQL error)
  • Leading slash broke GraphQL mutation
Example that failed:
yaml
collections:
  - name: root-pages
    folder: ""  # or "." or "/"
    # ← Broke when creating entries via GitHub backend
Use Case: VitePress and other frameworks storing content at repository root.
Status: Fixed in v0.125.0 (December 20, 2025)

问题:当集合的
folder: ""
folder: "."
folder: "/"
时,通过GitHub后端创建新条目会失败。GraphQL查询错误地构造了以
/
开头的绝对路径而非相对路径。
症状(v0.125.0之前):
  • 通过浏览器File API在本地正常工作
  • 通过GitHub后端失败(GraphQL错误)
  • 前导斜杠破坏了GraphQL mutation
失败示例
yaml
collections:
  - name: root-pages
    folder: ""  # 或 "." 或 "/"
    # ← 通过GitHub后端创建条目时失败
适用场景:VitePress和其他将内容存储在代码仓库根目录的框架。
状态:已在v0.125.0中修复(2025年12月20日)

Migration from Decap CMS

从Decap CMS迁移

Sveltia CMS is a drop-in replacement for Decap CMS.
Step 1: Update script tag (1 line change):
html
<!-- OLD: Decap CMS -->
<script src="https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js"></script>

<!-- NEW: Sveltia CMS -->
<script src="https://unpkg.com/@sveltia/cms@0.128.5/dist/sveltia-cms.js" type="module"></script>
Step 2: Keep existing config.yml (no changes needed)
Step 3: Test locally (verify login, content listing, editing, saving)
That's it! Your content, collections, and workflows remain unchanged.
Not Supported:
  • Git Gateway backend (for performance reasons)
  • Azure backend (may be added later)
Workaround: Use Cloudflare Workers or Vercel OAuth proxy instead.

Sveltia CMS是Decap CMS的直接替代方案
步骤1:更新脚本标签(仅需修改1行)
html
<!-- 旧:Decap CMS -->
<script src="https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js"></script>

<!-- 新:Sveltia CMS -->
<script src="https://unpkg.com/@sveltia/cms@0.128.5/dist/sveltia-cms.js" type="module"></script>
步骤2:保留现有config.yml(无需修改)
步骤3:本地测试(验证登录、内容列表、编辑、保存功能)
完成! 你的内容、集合和工作流均保持不变。
不支持的功能
  • Git Gateway后端(出于性能考虑)
  • Azure后端(可能后续添加)
替代方案:使用Cloudflare Workers或Vercel OAuth代理。

Bundled Resources

附带资源

Templates

模板

  • hugo/ - Complete Hugo blog setup
  • jekyll/ - Jekyll site configuration
  • 11ty/ - Eleventy blog setup
  • astro/ - Astro content collections
  • cloudflare-workers/ - OAuth proxy implementation
  • vercel-serverless/ - Vercel auth functions
  • collections/ - Pre-built collection patterns
  • hugo/ - 完整的Hugo博客搭建模板
  • jekyll/ - Jekyll站点配置模板
  • 11ty/ - Eleventy博客搭建模板
  • astro/ - Astro内容集合模板
  • cloudflare-workers/ - OAuth代理实现
  • vercel-serverless/ - Vercel认证函数
  • collections/ - 预构建的集合模式

References

参考文档

  • common-errors.md - Extended error troubleshooting
  • migration-from-decap.md - Complete migration guide
  • cloudflare-auth-setup.md - Step-by-step OAuth setup
  • config-reference.md - Full config.yml documentation
  • common-errors.md - 扩展错误排查指南
  • migration-from-decap.md - 完整迁移指南
  • cloudflare-auth-setup.md - 分步OAuth搭建指南
  • config-reference.md - 完整的config.yml文档

Scripts

脚本

  • init-sveltia.sh - Automated setup for new projects
  • deploy-cf-auth.sh - Deploy Cloudflare Workers OAuth
  • init-sveltia.sh - 新项目自动化搭建脚本
  • deploy-cf-auth.sh - 部署Cloudflare Workers OAuth的脚本

Official Documentation

官方文档

Note: The official documentation site is being actively developed. GitHub README remains a useful fallback for some topics.

注意:官方文档站点正在积极开发中。GitHub README仍是部分主题的有用替代。

Token Efficiency

令牌效率

Estimated Savings: 65-70% (~6,300 tokens saved)
Without Skill (~9,500 tokens):
  • Framework setup trial & error: 2,500 tokens
  • OAuth configuration attempts: 2,500 tokens
  • Error troubleshooting: 2,500 tokens
  • Deployment configuration: 2,000 tokens
With Skill (~3,200 tokens):
  • Skill loading (SKILL.md): 2,000 tokens
  • Template selection: 400 tokens
  • Project-specific adjustments: 800 tokens

预计节省:65-70%(约节省6300个令牌)
无此指南时(约9500个令牌):
  • 框架搭建试错:2500个令牌
  • OAuth配置尝试:2500个令牌
  • 错误排查:2500个令牌
  • 部署配置:2000个令牌
使用此指南时(约3200个令牌):
  • 加载指南(SKILL.md):2000个令牌
  • 模板选择:400个令牌
  • 项目特定调整:800个令牌

Errors Prevented

已避免的错误

This skill prevents 10 common errors (100% prevention rate):
  1. ✅ OAuth authentication failures
  2. ✅ TOML front matter generation bugs
  3. ✅ YAML parse errors (strict validation)
  4. ✅ Content not listing in CMS
  5. ✅ "SVELTIA is not defined" errors
  6. ✅ 404 on /admin page
  7. ✅ Image upload failures (HEIC format)
  8. ✅ Datetime widget format strictness / timezone issues
  9. ✅ GDPR violation (Google Fonts CDN)
  10. ✅ CORS / COOP policy errors

Last Updated: 2026-01-21 Skill Version: 2.1.0 Sveltia CMS Version: 0.128.5 (Beta) Status: Production-ready, v1.0 GA expected early 2026 Changes: Added 6 new configuration options (slug lowercase, raw format, number string encoding, locale URL param, richtext alias, Gemini 2.5 Flash-Lite support), updated datetime error with format strictness warning, added GDPR Google Fonts workaround, documented 2 fixed historical issues, deprecated slug_length option
本指南可100%避免以下10种常见错误:
  1. ✅ OAuth认证失败
  2. ✅ TOML前置元数据生成Bug
  3. ✅ YAML解析错误(严格验证)
  4. ✅ CMS中未显示内容
  5. ✅ "SVELTIA is not defined"错误
  6. ✅ /admin页面404
  7. ✅ 图片上传失败(HEIC格式)
  8. ✅ 日期时间小部件格式严格性/时区问题
  9. ✅ GDPR违规(Google Fonts CDN)
  10. ✅ CORS / COOP策略错误

最后更新:2026-01-21 指南版本:2.1.0 Sveltia CMS版本:0.128.5(测试版) 状态:可用于生产环境,预计2026年初发布v1.0正式版 变更:新增6个配置选项(slug小写、原始格式、数字字符串编码、语言URL参数、richtext别名、Gemini 2.5 Flash-Lite支持),更新了日期时间错误的格式严格性警告,添加了GDPR Google Fonts解决方法,记录了2个已修复的历史问题,弃用了slug_length选项