hugo-sveltia-cms
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHugo + Sveltia CMS Skill
Hugo + Sveltia CMS 技能指南
Two primary workflows:
- Bootstrap: New Hugo site with Sveltia CMS + Basecoat UI, deployed to Cloudflare Pages
- Convert: Migrate from TinaCMS, Decap/Netlify CMS, WordPress, Jekyll, Eleventy, or other platforms to Hugo + Sveltia CMS
两种核心工作流:
- 快速搭建:创建搭载Sveltia CMS + Basecoat UI的全新Hugo站点,并部署至Cloudflare Pages
- 迁移转换:将TinaCMS、Decap/Netlify CMS、WordPress、Jekyll、Eleventy或其他平台的站点迁移至Hugo + Sveltia CMS架构
Why This Stack
为何选择该技术栈
- Hugo — Fastest SSG, single binary, Go templates
- Sveltia CMS — Git-based headless CMS, drop-in Decap/Netlify CMS replacement with better UX and i18n. Beta, v1.0 early 2026. Same format as Decap
config.yml - Basecoat — shadcn/ui components without React. Tailwind CSS utility classes (,
btn,card), minimal JS, dark mode, themeableinput - Cloudflare Pages — Primary deploy target. Free tier, fast CDN, Workers for OAuth
- GitHub — Only supported Git backend
- Hugo — 速度最快的SSG,单二进制文件,基于Go模板
- Sveltia CMS — 基于Git的无头CMS,可无缝替代Decap/Netlify CMS,拥有更优的用户体验和国际化支持。当前为Beta版本,1.0版本预计2026年初发布。与Decap使用相同的配置格式
config.yml - Basecoat — 无需React的shadcn/ui组件库。提供Tailwind CSS工具类(如、
btn、card),仅含少量JS代码,支持深色模式和主题定制input - Cloudflare Pages — 首选部署目标。免费套餐、高速CDN,可通过Workers实现OAuth认证
- GitHub — 唯一支持的Git后端
Critical Knowledge
关键注意事项
- YAML front matter only. Sveltia CMS has bugs with TOML (). Always use YAML (
+++) and set---on every collection.format: yaml - Use not
hugo.yamlfor config consistency.hugo.toml - Admin files in . Hugo copies
static/admin/to build root.static/ - Media paths. (repo) →
media_folder: "static/images/uploads"(URL). Hugo stripspublic_folder: "/images/uploads".static/ - GitHub OAuth required. Deploy as a Cloudflare Worker. Netlify git-gateway NOT supported.
sveltia-cms-auth - Always set and
extension: "md"on every folder collection.format: "yaml" - Schema line at top of :
config.yml# yaml-language-server: $schema=https://unpkg.com/@sveltia/cms/schema/sveltia-cms.json
- 仅使用YAML前置元数据。Sveltia CMS在处理TOML()时存在Bug。请始终使用YAML(
+++),并为每个集合设置---。format: yaml - **使用**而非
hugo.yaml以保证配置一致性。hugo.toml - 管理文件存放于目录。Hugo会将
static/admin/目录内容复制到构建根目录。static/ - 媒体文件路径。(仓库路径)对应
media_folder: "static/images/uploads"(访问URL)。Hugo会自动去除public_folder: "/images/uploads"前缀。static/ - 必须配置GitHub OAuth。将部署为Cloudflare Worker。不支持Netlify git-gateway。
sveltia-cms-auth - 务必为每个文件夹集合设置和
extension: "md"。format: "yaml" - 顶部需添加Schema行:
config.yml# yaml-language-server: $schema=https://unpkg.com/@sveltia/cms/schema/sveltia-cms.json
Workflow: Bootstrap
工作流:快速搭建
Step 1: Gather Requirements
步骤1:收集需求
Ask:
- Site purpose: Consulting/services, medical practice, blog, portfolio, docs?
- Content types: What content will they manage?
- Basecoat approach: Full Tailwind pipeline (recommended) or CDN-only prototype?
- Custom domain: For CF Pages + OAuth setup
询问用户:
- 站点用途:咨询/服务、医疗诊所、博客、作品集、文档站?
- 内容类型:需要管理哪些类型的内容?
- Basecoat集成方式:完整Tailwind流水线(推荐)还是仅CDN引入的原型?
- 自定义域名:用于Cloudflare Pages + OAuth配置
Step 2: Scaffold Hugo + Basecoat
步骤2:搭建Hugo + Basecoat框架
bash
hugo new site <site-name> --format yaml
cd <site-name>Read for setup details.
references/hugo-sveltia-setup.md § Basecoat IntegrationProduction (recommended): , create with , wire via Hugo's pipe.
npm init -y && npm install -D tailwindcss @tailwindcss/cli basecoat-cssassets/css/main.css@import "tailwindcss"; @import "basecoat-css";css.TailwindCSSCDN (quick start): Add CDN links to .
baseof.html<head>bash
hugo new site <site-name> --format yaml
cd <site-name>查看获取详细配置说明。
references/hugo-sveltia-setup.md § Basecoat Integration生产环境(推荐):执行,创建并添加,通过Hugo的管道引入。
npm init -y && npm install -D tailwindcss @tailwindcss/cli basecoat-cssassets/css/main.css@import "tailwindcss"; @import "basecoat-css";css.TailwindCSS快速原型(仅CDN):在的中添加CDN链接。
baseof.html<head>Step 3: Create Admin Interface
步骤3:创建管理界面
Create and using . Build collections from the domain-specific patterns in the reference file.
static/admin/index.htmlstatic/admin/config.ymltemplates/使用模板创建和。参考文档中的领域特定模式构建集合。
templates/static/admin/index.htmlstatic/admin/config.ymlStep 4: Build Layouts with Basecoat Components
步骤4:使用Basecoat组件构建布局
Create Hugo partials wrapping Basecoat classes: , , , , . These accept parameters via Hugo and emit styled HTML.
partials/components/card.htmlbutton.htmlbadge.htmlalert.htmlnav.htmldict创建封装Basecoat类的Hugo局部模板:、、、、。这些模板可通过Hugo接收参数并生成样式化HTML。
partials/components/card.htmlbutton.htmlbadge.htmlalert.htmlnav.htmldictStep 5: Create Archetypes + Seed Content
步骤5:创建原型模板 + 初始内容
One archetype per content type in .
archetypes/在目录中为每种内容类型创建一个原型模板。
archetypes/Step 6: Deploy to Cloudflare Pages
步骤6:部署至Cloudflare Pages
- Register GitHub OAuth App → get Client ID + Secret
- Deploy Cloudflare Worker
sveltia-cms-auth - Connect repo to CF Pages, set env var
HUGO_VERSION - Build command: , output:
hugo --minifypublic - The bootstrap creates automatically — set
.github/workflows/deploy.yml,CLOUDFLARE_API_TOKENas GitHub Secrets andCLOUDFLARE_ACCOUNT_IDas a GitHub VariablePAGES_PROJECT_NAME
- 注册GitHub OAuth应用 → 获取客户端ID和密钥
- 部署Cloudflare Worker
sveltia-cms-auth - 将仓库连接至Cloudflare Pages,设置环境变量
HUGO_VERSION - 构建命令:,输出目录:
hugo --minifypublic - 快速搭建流程会自动创建— 在GitHub Secrets中设置
.github/workflows/deploy.yml、CLOUDFLARE_API_TOKEN,并在GitHub Variables中设置CLOUDFLARE_ACCOUNT_IDPAGES_PROJECT_NAME
Step 7: Test Locally
步骤7:本地测试
Sveltia CMS detects localhost and uses File System Access API (Chromium) — no OAuth needed locally. Run , visit .
hugo server/admin/Sveltia CMS会自动检测本地环境并使用文件系统访问API(Chromium浏览器)—— 本地测试无需OAuth认证。运行,访问即可。
hugo server/admin/Workflow: Convert
工作流:迁移转换
From TinaCMS
从TinaCMS迁移
TinaCMS uses GraphQL API + schema + TinaCloud auth. Fundamentally different architecture.
tina/config.tsField type mapping:
TinaCMS | Sveltia | Notes |
|---|---|---|
| | |
| | |
| | |
| | |
| | |
| | Shortcode templates won't carry over |
| | Map subfields recursively |
| | Set |
| | Set |
Config mapping: →
tina/config.tscollections[].pathconfig.ymlcollections[].folderSteps:
- Read , map each collection's fields using table above
tina/config.{ts,js} - Content files (Markdown + YAML front matter) stay as-is — Hugo reads them directly
- Delete directory, remove
tina/fromtinacms, remove Tina build commandspackage.json - Create with Sveltia CMS files
static/admin/ - Map Tina media config (/
mediaRoot) → SveltiapublicFolder/media_folderpublic_folder - Document shortcodes used in content (no CMS-side visual editing for these)
- Deploy via CF Pages + GitHub OAuth
Key win: No more TinaCloud dependency, no GraphQL build step, no .
tina/__generated__/TinaCMS采用GraphQL API + 配置 + TinaCloud认证,架构差异较大。
tina/config.ts字段类型映射:
TinaCMS | Sveltia | 说明 |
|---|---|---|
| | |
| | |
| | |
| | |
| | |
| | 短代码模板无法直接迁移 |
| | 递归映射子字段 |
| | 设置 |
| | 设置 |
配置映射:中的对应中的
tina/config.tscollections[].pathconfig.ymlcollections[].folder迁移步骤:
- 读取,根据上表映射每个集合的字段
tina/config.{ts,js} - 内容文件(Markdown + YAML前置元数据)可直接保留 — Hugo可直接读取
- 删除目录,从
tina/中移除package.json依赖,删除Tina相关构建命令tinacms - 创建目录并添加Sveltia CMS文件
static/admin/ - 将Tina媒体配置(/
mediaRoot)映射为Sveltia的publicFolder/media_folderpublic_folder - 记录内容中使用的短代码(CMS端无法可视化编辑这些短代码)
- 通过Cloudflare Pages + GitHub OAuth部署站点
核心优势: 不再依赖TinaCloud,无需GraphQL构建步骤,无目录。
tina/__generated__/From Decap CMS / Netlify CMS
从Decap CMS / Netlify CMS迁移
Drop-in replacement:
- Replace script tag:
<script src="https://unpkg.com/@sveltia/cms/dist/sveltia-cms.js"></script> - Existing works as-is
config.yml - Replace with GitHub OAuth + CF Worker
git-gateway - Test all collections
无缝替代:
- 替换脚本标签为:
<script src="https://unpkg.com/@sveltia/cms/dist/sveltia-cms.js"></script> - 现有可直接使用
config.yml - 将替换为GitHub OAuth + Cloudflare Worker
git-gateway - 测试所有集合
From WordPress
从WordPress迁移
- Export via or
wordpress-export-to-markdownafter Jekyll exporthugo import jekyll - Clean front matter (strip ,
wp_id)guid - Map taxonomies → Hugo taxonomies
- Download media →
static/images/ - Build collections matching cleaned structure
- 使用工具导出,或先导出至Jekyll再使用
wordpress-export-to-markdown导入hugo import jekyll - 清理前置元数据(移除、
wp_id字段)guid - 将WordPress分类法映射为Hugo分类法
- 下载媒体文件至目录
static/images/ - 根据清理后的内容结构构建集合
From Jekyll
从Jekyll迁移
- (built-in)
hugo import jekyll <jekyll-root> <hugo-root> - Review front matter, add Sveltia CMS per standard workflow
- 使用内置命令
hugo import jekyll <jekyll-root> <hugo-root> - 检查前置元数据,按照标准流程添加Sveltia CMS
From Eleventy / Other SSGs
从Eleventy / 其他SSG迁移
- Copy Markdown + YAML front matter files into
content/ - Adjust for Hugo conventions (format,
dateboolean)draft - Rebuild templates in Hugo, add Sveltia CMS
- 将Markdown + YAML前置元数据文件复制至目录
content/ - 调整为Hugo规范(如格式、
date布尔值)draft - 重新构建Hugo模板,添加Sveltia CMS
Domain-Specific Collections
领域特定集合
Read for ready-made configs:
references/hugo-sveltia-setup.md § Domain Collection Patterns- Consulting / Services — Services, case studies, testimonials, team members
- Medical Practice — Providers, locations, services/specialties, conditions, patient resources
- Content / Blog — Posts, pages, authors, newsletter, categories
Mix and match. Each includes full field definitions.
查看获取现成配置:
references/hugo-sveltia-setup.md § Domain Collection Patterns- 咨询/服务站 — 服务项目、案例研究、客户评价、团队成员
- 医疗诊所站 — 医护人员、诊所位置、服务/专科、病症信息、患者资源
- 内容/博客站 — 文章、页面、作者、通讯、分类
可按需组合使用。每个集合包含完整的字段定义。
File Checklist
文件检查清单
-
hugo.yaml - +
package.json(Basecoat/Tailwind, if npm path)assets/css/main.css - +
static/admin/index.htmlstatic/admin/config.yml - — one per content type
archetypes/ - — seed or converted content
content/ - — Basecoat-styled templates + component partials
layouts/ - — CI/CD for Cloudflare Pages
.github/workflows/deploy.yml -
.gitignore
-
hugo.yaml - +
package.json(若使用npm方式集成Basecoat/Tailwind)assets/css/main.css - +
static/admin/index.htmlstatic/admin/config.yml - — 每种内容类型对应一个原型模板
archetypes/ - — 初始或迁移后的内容
content/ - — Basecoat样式模板 + 组件局部模板
layouts/ - — Cloudflare Pages CI/CD的GitHub Actions工作流
.github/workflows/deploy.yml -
.gitignore
Reference Files
参考文件
- — Full config reference, domain collections, Basecoat setup, widgets, auth, CF Pages deploy, gotchas, i18n
references/hugo-sveltia-setup.md - — Admin page template
templates/admin-index.html - — Annotated CMS config starter
templates/config.yml - — GitHub Actions workflow for Cloudflare Pages CI/CD
templates/deploy.yml - — One-command scaffolding
scripts/bootstrap-hugo-sveltia.sh - — Batch front matter conversion
scripts/convert-toml-to-yaml.py
- — 完整配置参考、领域集合、Basecoat配置、组件、认证、Cloudflare Pages部署、注意事项、国际化
references/hugo-sveltia-setup.md - — 管理页面模板
templates/admin-index.html - — 带注释的CMS配置模板
templates/config.yml - — Cloudflare Pages CI/CD的GitHub Actions工作流模板
templates/deploy.yml - — 一键搭建脚本
scripts/bootstrap-hugo-sveltia.sh - — 批量前置元数据转换脚本
scripts/convert-toml-to-yaml.py