抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

前言

静态网站建站成本低、安全、轻量,但最大的缺点就是没有后台,更新网站麻烦。Decap CMS 就能解决这个问题

本文将介绍 Decap CMS,并详细讲解 Decap CMS 部署教程。让你能在线更新你的静态网站。

注意,本篇教程一气呵成(😂),请紧跟步伐。

Decap CMS 简介

Decap CMS

Decap CMS(以前称为 Netlify CMS)是一个基于 Git 且开源的内容管理系统(CMS),专为静态网站和无头(headless)CMS架构而设计。它主要与静态站点生成器(如 Hexo、Jekyll、Hugo 等)结合使用,允许用户通过一个直观的图形界面管理网站内容。

开源免费,在 Github 上有 17.7k 的 Star。

优点

  • 无需服务器
  • 开源
  • 入门简单(个人觉得)
  • 友好的用户界面
  • 无需 GitHub 帐户即可立即访问
  • 基于 Git 管理
  • 自动保存文章备份到本地(localStorage

缺点

  • 界面不太好看(应该是我的要求太高了),对移动端不太友好
  • 只能码一些文章,修改一下文件,就没有其它功能了(我在期待一些什么?)
  • 在其它网站按全选复制后,在 Decap CMS 粘贴后不能转换为 Markdown(快速抄作业)

部署前的准备

  • 有个 GitHub 账户,并在 Github 上有个 Rope 存放着你的博客源码
  • 有个 Netlify 账户,并有个 Site 连接到 博客源码 Rope
  • 对 Hexo 有一定的了解

开始

本文可以简单分成三部分,个人觉得最难的是 source\admin\config.yml 的配置,照着 configuration-options 一点一点地配置。

  1. 配置 Netlify
  2. Hexo 源码及前端修改
  3. 进入你的 Decap CMS

配置 Netlify

在 Netlify 打开你的网站,打开 Site configuration > Identity ,点击 Enable Identity 开启 Netlify Identity。

下滑,找到 Registration preferences,点击 Configure,把 Registration 设置为 Invite only,按住 Ctrl 键点击 Identity tab 在新标签打开,待会用到。

继续下滑,找到 Git Gateway,点击 Enable Git Gateway 开启它。

至此,该标签页可以关闭了,下面切换到 Identity tab 标签页,点击 Invite users,输入你的邮箱,点击 Send,你邮箱会收到一封邀请邮件,不过暂时不用管它。

Netlify 配置至此完成。

Hexo 源码及前端修改

修改 _config.yml,跳过对 admin 目录的渲染。admin 为待要配置 Decap CMS 的地方,如果你要修改为其他 path,这也是可以的,但记得要把下文的 admin 都改为你的 path

_config.yml
1
2
skip_render:
- 'admin/**/*'

新建目录 source\admin,在该目录下新建 index.html,粘贴下面的代码。

source\admin\index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="x-UA-Compatible" content="IE=Edge">
<meta name="robots" content="noindex" />
<title>Decap CMS</title>
<!-- <link rel="icon" type="image/svg+xml" sizes="180x180" href="favicon.svg"> -->
<script type="text/javascript" src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
<link href="/admin/config.yml" type="text/yaml" rel="cms-config-url">
</head>
<body>
<script src="https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js"></script>
</body>
</html>

新建 config.yml,粘贴下面的代码。

示例代码
source\admin\config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
backend:
name: git-gateway
branch: master # 要更新的分支(可选;默认为主分支)
commit_messages:
create: Create {{collection}} “{{slug}}”
update: Update {{collection}} “{{slug}}”
delete: Delete {{collection}} “{{slug}}”
uploadMedia: Upload “{{path}}”
deleteMedia: Delete “{{path}}”
openAuthoring: '{{message}}'


logo_url: /favicon.svg # 你的 logo


# 禁用部署预览链接
# show_preview_links: false


# This line should *not* be indented
publish_mode: editorial_workflow


# This line should *not* be indented
media_folder: "source/images/uploads" # 媒体文件将存储在图片/上载下的Repo中。
public_folder: "/images/uploads" # 上传的媒体的src属性将以/images/uploads开头。


site_url: https://xxxxxx.org/ # 网站网址
display_url: https://xxxxxx.org/ # 显示网址


locale: "zh_Hans" # 语言环境


collections:


- name: "posts" # 在路由中使用,例如:/admin/collections/blog。
label: "Posts" # 在用户界面中使用
folder: "source/_posts/" # 存储文件的文件夹的路径。
# filter: {field: "categories", value: "Posts"} # 筛选
create: true # 允许用户在这个集合中创建新的文件。
fields: # 每份文件的字段,通常是前面的内容。
- {label: "标题", name: "title", default: "Posts: ", widget: "string"}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "标签", name: "tags", widget: "list", required: false}
- {label: "分类", name: "categories", widget: "list", required: false}
- {label: "关键词", name: "keywords", widget: "list", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "永久链接", name: "permalink", widget: "string", required: false}
- {label: "评论", name: "comments", widget: "boolean", default: true, required: false}
- {label: "置顶", name: "pin", widget: "boolean", default: false, required: false}
- {label: "密码", name: "password", widget: "string", required: false}
- {label: "abstract", name: "abstract", default: "有东西被加密了, 请输入密码查看.", widget: "string", required: false}
- {label: "message", name: "message", default: "您好, 这里需要密码.", widget: "string", required: false}
- {label: "wrong_pass_message", name: "wrong_pass_message", default: "抱歉, 这个密码看着不太对, 请再试试.", widget: "string", required: false}
- {label: "wrong_hash_message", name: "wrong_hash_message", default: "抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}




# - name: "pages"
# label: "Pages"
# files:
# - file: "source/about/index.md"
# name: "about"
# label: "关于"
# fields:
# - {label: "标题", name: "title", widget: "string"}
# - {label: "评论", name: "comments", widget: "boolean", default: false, required: false}
# - {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
# - {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
# - {label: "layout", name: "layout", widget: "string", required: false}
# - {label: "摘要", name: "description", widget: "string", required: false}
# - {label: "内容", name: "body", widget: "markdown", required: false}


# - name: all
# label: 'all posts and pages (测试)'
# folder: 'source'
# create: true
# # 添加嵌套对象将显示集合文件夹结构
# nested:
# depth: 100 # 在收藏树中显示的最大深度
# summary: '{{title}}' # 树节点的可选摘要,默认为推断出的标题字段
# fields:
# - {label: "标题", name: "title", widget: "string"}
# - {label: "评论", name: "comments", widget: "boolean", default: false, required: false}
# - {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
# - {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
# - {label: "layout", name: "layout", widget: "string", required: false}
# - {label: "摘要", name: "description", widget: "string", required: false}
# - {label: "密码", name: "password", widget: "string", required: false}
# - {label: "abstract", name: "abstract", default: "有东西被加密了, 请输入密码查看.", widget: "string", required: false}
# - {label: "message", name: "message", default: "您好, 这里需要密码.", widget: "string", required: false}
# - {label: "wrong_pass_message", name: "wrong_pass_message", default: "抱歉, 这个密码看着不太对, 请再试试.", widget: "string", required: false}
# - {label: "wrong_hash_message", name: "wrong_hash_message", default: "抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.", widget: "string", required: false}
# - {label: "内容", name: "body", widget: "markdown", required: false}
# # 添加带有路径属性的元对象,可以编辑条目的路径
# # 移动现有条目会将该条目整个子树移动到新位置
# meta: { path: { widget: string, label: 'Path', index_file: 'index' } }


# - name: 'data'
# label: 'Data'
# label_singular: 'data'
# description: 'Manage the list of data.'
# files:
# - name: 'friends'
# label: 'Friends List'
# file: 'source/_data/friends.yml'
# fields:
# - label: 'friendlinks'
# name: 'friendlinks'
# widget: 'list'
# fields:
# - label: '分组标题'
# name: 'group'
# widget: 'string'
# - label: '分组描述'
# name: 'description'
# widget: 'string'
# required: false
# - label: 'Items'
# name: 'items'
# widget: 'list'
# fields:
# - label: '名称'
# name: 'title'
# widget: 'string'
# - label: '头像'
# name: 'avatar'
# widget: 'string'
# - label: '链接'
# name: 'url'
# widget: 'string'
# - label: '日期'
# name: 'adddate'
# widget: "datetime"
# format: "YYYY-MM-DD HH:mm:ss"
# dateFormat: "YYYY-MM-DD"
# timeFormat: "HH:mm:ss"
# required: false
# - label: 'RSS'
# name: 'rss'
# widget: 'string'
# required: false
# - label: '联系方式'
# name: 'contact'
# widget: 'string'
# required: false
# - label: '截图'
# name: 'screenshot'
# widget: 'string'
# required: false
# - label: '关键词'
# name: 'keywords'
# widget: 'string'
# required: false
# - label: '描述'
# name: 'description'
# widget: 'string'
# required: false
# - name: 'sites'
# label: 'Sites List'
# file: 'source/_data/sites.yml'
# fields:
# - label: 'sites'
# name: 'sites'
# widget: 'list'
# fields:
# - label: '分组标题'
# name: 'group'
# widget: 'string'
# - label: '分组描述'
# name: 'description'
# widget: 'string'
# required: false
# - label: 'Items'
# name: 'items'
# widget: 'list'
# fields:
# - label: '名称'
# name: 'title'
# widget: 'string'
# - label: '头像'
# name: 'avatar'
# widget: 'string'
# - label: '链接'
# name: 'url'
# widget: 'string'
# - label: '截图'
# name: 'screenshot'
# widget: 'string'
# required: false
# - label: '关键词'
# name: 'keywords'
# widget: 'string'
# required: false
# - label: '描述'
# name: 'description'
# widget: 'string'
# required: false

请将上面的配置中的 logo_urlsite_urldisplay_url 改为你自己的。

source\admin\config.yml
1
2
3
logo_url: /favicon.svg # 你的 logo
site_url: https://xxxxx.org/ # 网站网址
display_url: https://xxxxx.org/ # 显示网址

这只是个示例的配置文件,通过修改配置文件可以实现在 Decap CMS 上新建发布文章、添加或修改页面、添加友链链接、修改主题配置等。

配置文件的内容过于复杂繁琐,怒不在此处一一讲解。请到官网的 configuration-options上完成你的个性化配置。

附上我的代码
source\admin\config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
backend:
name: git-gateway
branch: master # 要更新的分支(可选;默认为主分支)
commit_messages:
create: Create {{collection}} “{{slug}}”
update: Update {{collection}} “{{slug}}”
delete: Delete {{collection}} “{{slug}}”
uploadMedia: Upload “{{path}}”
deleteMedia: Delete “{{path}}”
openAuthoring: '{{message}}'


logo_url: https://assets.buasis.eu.org/me/favicon.svg


# 禁用部署预览链接
# show_preview_links: false


# This line should *not* be indented
publish_mode: editorial_workflow


# This line should *not* be indented
media_folder: "source/images/uploads" # 媒体文件将存储在图片/上载下的Repo中。
public_folder: "/images/uploads" # 上传的媒体的src属性将以/images/uploads开头。


site_url: https://buasis.eu.org/ # 网站网址
display_url: https://buasis.eu.org/ # 显示网址


locale: "zh_Hans" # 语言环境


collections:


- name: "all-posts" # 在路由中使用,例如:/admin/collections/blog。
label: "All-Posts" # 在用户界面中使用
folder: "source/_posts/" # 存储文件的文件夹的路径。
# filter: {field: "categories", value: "Posts"}
create: false # 允许用户在这个集合中创建新的文件。
fields: # 每份文件的字段,通常是前面的内容。
- {label: "标题", name: "title", default: "Posts: ", widget: "string"}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "标签", name: "tags", widget: "list", required: false}
- {label: "分类", name: "categories", widget: "list", required: false}
- {label: "关键词", name: "keywords", widget: "list", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "永久链接", name: "permalink", widget: "string", required: false}
- {label: "评论", name: "comments", widget: "boolean", default: true, required: false}
- {label: "置顶", name: "pin", widget: "boolean", default: false, required: false}
- {label: "密码", name: "password", widget: "string", required: false}
- {label: "abstract", name: "abstract", default: "有东西被加密了, 请输入密码查看.", widget: "string", required: false}
- {label: "message", name: "message", default: "您好, 这里需要密码.", widget: "string", required: false}
- {label: "wrong_pass_message", name: "wrong_pass_message", default: "抱歉, 这个密码看着不太对, 请再试试.", widget: "string", required: false}
- {label: "wrong_hash_message", name: "wrong_hash_message", default: "抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}


- name: "posts" # 在路由中使用,例如:/admin/collections/blog。
label: "Posts" # 在用户界面中使用
folder: "source/_posts/" # 存储文件的文件夹的路径。
filter: {field: "categories", value: "Posts"}
create: true # 允许用户在这个集合中创建新的文件。
fields: # 每份文件的字段,通常是前面的内容。
- {label: "标题", name: "title", default: "Posts: ", widget: "string"}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "标签", name: "tags", widget: "list", required: false}
- {label: "分类", name: "categories", default: "Posts", widget: "list", required: false}
- {label: "关键词", name: "keywords", widget: "list", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "永久链接", name: "permalink", widget: "string", required: false}
- {label: "评论", name: "comments", widget: "boolean", default: true, required: false}
- {label: "置顶", name: "pin", widget: "boolean", default: false, required: false}
- {label: "密码", name: "password", widget: "string", required: false}
- {label: "abstract", name: "abstract", default: "有东西被加密了, 请输入密码查看.", widget: "string", required: false}
- {label: "message", name: "message", default: "您好, 这里需要密码.", widget: "string", required: false}
- {label: "wrong_pass_message", name: "wrong_pass_message", default: "抱歉, 这个密码看着不太对, 请再试试.", widget: "string", required: false}
- {label: "wrong_hash_message", name: "wrong_hash_message", default: "抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}


- name: "ssn" # 在路由中使用,例如:/admin/collections/blog。
label: "碎碎念" # 在用户界面中使用
folder: "source/_posts" # 存储文件的文件夹的路径。
filter: {field: "categories", value: "碎碎念"}
create: true # 允许用户在这个集合中创建新的文件。
fields: # 每份文件的字段,通常是前面的内容。
- {label: "标题", name: "title", default: "碎碎念: ", widget: "string"}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "标签", name: "tags", widget: "list", default: "S:N" , required: true}
- {label: "分类", name: "categories", widget: "list", default: "碎碎念", required: false}
- {label: "关键词", name: "keywords", widget: "list", required: false}
- {label: "摘要", name: "description", widget: "list", required: false}
- {label: "永久链接", name: "permalink", widget: "string", required: false}
- {label: "评论", name: "comments", widget: "boolean", default: true, required: false}
- {label: "置顶", name: "pin", widget: "boolean", default: false, required: false}
- {label: "密码", name: "password", widget: "string", required: false}
- {label: "abstract", name: "abstract", default: "有东西被加密了, 请输入密码查看.", widget: "string", required: false}
- {label: "message", name: "message", default: "您好, 这里需要密码.", widget: "string", required: false}
- {label: "wrong_pass_message", name: "wrong_pass_message", default: "抱歉, 这个密码看着不太对, 请再试试.", widget: "string", required: false}
- {label: "wrong_hash_message", name: "wrong_hash_message", default: "抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}




- name: "sy" # 在路由中使用,例如:/admin/collections/blog。
label: "摄影" # 在用户界面中使用
folder: "source/_posts" # 存储文件的文件夹的路径。
filter: {field: "categories", value: "摄影"}
create: true # 允许用户在这个集合中创建新的文件。
fields: # 每份文件的字段,通常是前面的内容。
- {label: "标题", name: "title", default: "摄影: ", widget: "string"}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "标签", name: "tags", widget: "list", required: false}
- {label: "分类", name: "categories", widget: "list", default: "摄影", required: false}
- {label: "关键词", name: "keywords", widget: "list", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "永久链接", name: "permalink", widget: "string", required: false}
- {label: "评论", name: "comments", widget: "boolean", default: true, required: false}
- {label: "置顶", name: "pin", widget: "boolean", default: false, required: false}
- {label: "密码", name: "password", widget: "string", required: false}
- {label: "abstract", name: "abstract", default: "有东西被加密了, 请输入密码查看.", widget: "string", required: false}
- {label: "message", name: "message", default: "您好, 这里需要密码.", widget: "string", required: false}
- {label: "wrong_pass_message", name: "wrong_pass_message", default: "抱歉, 这个密码看着不太对, 请再试试.", widget: "string", required: false}
- {label: "wrong_hash_message", name: "wrong_hash_message", default: "抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}


- name: "zc" # 在路由中使用,例如:/admin/collections/blog。
label: "摘抄" # 在用户界面中使用
folder: "source/_posts/zc" # 存储文件的文件夹的路径。
filter: {field: "categories", value: "摘抄"}
create: true # 允许用户在这个集合中创建新的文件。
fields: # 每份文件的字段,通常是前面的内容。
- {label: "标题", name: "title", default: "摘抄: ", widget: "string"}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "标签", name: "tags", widget: "list", required: false}
- {label: "分类", name: "categories", widget: "list", default: "摘抄", required: false}
- {label: "关键词", name: "keywords", widget: "list", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "永久链接", name: "permalink", widget: "string", required: false}
- {label: "评论", name: "comments", widget: "boolean", default: true, required: false}
- {label: "置顶", name: "pin", widget: "boolean", default: false, required: false}
- {label: "密码", name: "password", widget: "string", required: false}
- {label: "abstract", name: "abstract", default: "有东西被加密了, 请输入密码查看.", widget: "string", required: false}
- {label: "message", name: "message", default: "您好, 这里需要密码.", widget: "string", required: false}
- {label: "wrong_pass_message", name: "wrong_pass_message", default: "抱歉, 这个密码看着不太对, 请再试试.", widget: "string", required: false}
- {label: "wrong_hash_message", name: "wrong_hash_message", default: "抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}


- name: "bj" # 在路由中使用,例如:/admin/collections/blog。
label: "便笺" # 在用户界面中使用
folder: "source/_posts/bj" # 存储文件的文件夹的路径。
filter: {field: "categories", value: "便笺"}
create: true # 允许用户在这个集合中创建新的文件。
fields: # 每份文件的字段,通常是前面的内容。
- {label: "标题", name: "title", default: "便笺: ", widget: "string"}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "标签", name: "tags", widget: "list", required: false}
- {label: "分类", name: "categories", widget: "list", default: "便笺", required: false}
- {label: "关键词", name: "keywords", widget: "list", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "永久链接", name: "permalink", widget: "string", required: false}
- {label: "评论", name: "comments", widget: "boolean", default: true, required: false}
- {label: "置顶", name: "pin", widget: "boolean", default: false, required: false}
- {label: "密码", name: "password", widget: "string", required: false}
- {label: "abstract", name: "abstract", default: "有东西被加密了, 请输入密码查看.", widget: "string", required: false}
- {label: "message", name: "message", default: "您好, 这里需要密码.", widget: "string", required: false}
- {label: "wrong_pass_message", name: "wrong_pass_message", default: "抱歉, 这个密码看着不太对, 请再试试.", widget: "string", required: false}
- {label: "wrong_hash_message", name: "wrong_hash_message", default: "抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}


- name: "pages"
label: "Pages"
files:
- file: "source/about/index.md"
name: "about"
label: "关于"
fields:
- {label: "标题", name: "title", widget: "string"}
- {label: "评论", name: "comments", widget: "boolean", default: false, required: false}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "layout", name: "layout", widget: "string", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}


- file: "source/all-web/index.md"
name: "all-web"
label: "All-Web"
fields:
- {label: "标题", name: "title", widget: "string"}
- {label: "评论", name: "comments", widget: "boolean", default: false, required: false}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "密码", name: "password", widget: "string", required: false}
- {label: "abstract", name: "abstract", default: "有东西被加密了, 请输入密码查看.", widget: "string", required: false}
- {label: "message", name: "message", default: "您好, 这里需要密码.", widget: "string", required: false}
- {label: "wrong_pass_message", name: "wrong_pass_message", default: "抱歉, 这个密码看着不太对, 请再试试.", widget: "string", required: false}
- {label: "wrong_hash_message", name: "wrong_hash_message", default: "抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.", widget: "string", required: false}
- {label: "layout", name: "layout", widget: "string", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}


- file: "source/music/index.md"
name: "music"
label: "网易云音乐"
fields:
- {label: "标题", name: "title", widget: "string"}
- {label: "评论", name: "comments", widget: "boolean", default: false, required: false}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "layout", name: "layout", widget: "string", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}


- file: "source/name/index.md"
name: "name"
label: "NAME MD5值"
fields:
- {label: "标题", name: "title", widget: "string"}
- {label: "评论", name: "comments", widget: "boolean", default: false, required: false}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "密码", name: "password", widget: "string", required: false}
- {label: "abstract", name: "abstract", default: "有东西被加密了, 请输入密码查看.", widget: "string", required: false}
- {label: "message", name: "message", default: "您好, 这里需要密码.", widget: "string", required: false}
- {label: "wrong_pass_message", name: "wrong_pass_message", default: "抱歉, 这个密码看着不太对, 请再试试.", widget: "string", required: false}
- {label: "wrong_hash_message", name: "wrong_hash_message", default: "抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.", widget: "string", required: false}
- {label: "layout", name: "layout", widget: "string", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}

- file: "source/reading/index.md"
name: "reading"
label: "阅读足迹"
fields:
- {label: "标题", name: "title", widget: "string"}
- {label: "评论", name: "comments", widget: "boolean", default: false, required: false}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "密码", name: "password", widget: "string", required: false}
- {label: "abstract", name: "abstract", default: "有东西被加密了, 请输入密码查看.", widget: "string", required: false}
- {label: "message", name: "message", default: "您好, 这里需要密码.", widget: "string", required: false}
- {label: "wrong_pass_message", name: "wrong_pass_message", default: "抱歉, 这个密码看着不太对, 请再试试.", widget: "string", required: false}
- {label: "wrong_hash_message", name: "wrong_hash_message", default: "抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.", widget: "string", required: false}
- {label: "layout", name: "layout", widget: "string", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}


- file: "source/software/index.md"
name: "software"
label: "我的宝藏软件"
fields:
- {label: "标题", name: "title", widget: "string"}
- {label: "评论", name: "comments", widget: "boolean", default: false, required: false}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "layout", name: "layout", widget: "string", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}


- file: "source/friends/index.md"
name: "friends"
label: "友链"
fields:
- {label: "标题", name: "title", widget: "string"}
- {label: "评论", name: "comments", widget: "boolean", default: false, required: false}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "layout", name: "layout", widget: "string", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}


- name: pages-test
label: 'Pages (测试)'
label_singular: 'Page'
folder: 'source'
create: true
# 添加嵌套对象将显示集合文件夹结构
nested:
depth: 100 # 在收藏树中显示的最大深度
summary: '{{title}}' # 树节点的可选摘要,默认为推断出的标题字段
filter:
exclude:
- '_post' # 排除 source/_post 文件夹中的内容
fields:
- {label: "标题", name: "title", widget: "string"}
- {label: "评论", name: "comments", widget: "boolean", default: false, required: false}
- {label: "发布日期", name: "date", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "更新日期", name: "updated", widget: "datetime", format: "YYYY-MM-DD HH:mm:ss", dateFormat: "YYYY-MM-DD", timeFormat: "HH:mm:ss", required: false}
- {label: "layout", name: "layout", widget: "string", required: false}
- {label: "摘要", name: "description", widget: "string", required: false}
- {label: "密码", name: "password", widget: "string", required: false}
- {label: "abstract", name: "abstract", default: "有东西被加密了, 请输入密码查看.", widget: "string", required: false}
- {label: "message", name: "message", default: "您好, 这里需要密码.", widget: "string", required: false}
- {label: "wrong_pass_message", name: "wrong_pass_message", default: "抱歉, 这个密码看着不太对, 请再试试.", widget: "string", required: false}
- {label: "wrong_hash_message", name: "wrong_hash_message", default: "抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.", widget: "string", required: false}
- {label: "内容", name: "body", widget: "markdown", required: false}
# 添加带有路径属性的元对象,可以编辑条目的路径
# 移动现有条目会将该条目整个子树移动到新位置
meta: { path: { widget: string, label: 'Path', index_file: 'index' } }


- name: 'data'
label: 'Data'
label_singular: 'data'
description: 'Manage the list of data.'
files:
- name: 'friends'
label: 'Friends List'
file: 'source/_data/friends.yml'
fields:
- label: 'friendlinks'
name: 'friendlinks'
widget: 'list'
fields:
- label: '分组标题'
name: 'group'
widget: 'string'
- label: '分组描述'
name: 'description'
widget: 'string'
required: false
- label: 'Items'
name: 'items'
widget: 'list'
fields:
- label: '名称'
name: 'title'
widget: 'string'
- label: '头像'
name: 'avatar'
widget: 'string'
- label: '链接'
name: 'url'
widget: 'string'
- label: '日期'
name: 'adddate'
widget: "datetime"
format: "YYYY-MM-DD HH:mm:ss"
dateFormat: "YYYY-MM-DD"
timeFormat: "HH:mm:ss"
required: false
- label: 'RSS'
name: 'rss'
widget: 'string'
required: false
- label: '联系方式'
name: 'contact'
widget: 'string'
required: false
- label: '截图'
name: 'screenshot'
widget: 'string'
required: false
- label: '关键词'
name: 'keywords'
widget: 'string'
required: false
- label: '描述'
name: 'description'
widget: 'string'
required: false
- name: 'sites'
label: 'Sites List'
file: 'source/_data/sites.yml'
fields:
- label: 'sites'
name: 'sites'
widget: 'list'
fields:
- label: '分组标题'
name: 'group'
widget: 'string'
- label: '分组描述'
name: 'description'
widget: 'string'
required: false
- label: 'Items'
name: 'items'
widget: 'list'
fields:
- label: '名称'
name: 'title'
widget: 'string'
- label: '头像'
name: 'avatar'
widget: 'string'
- label: '链接'
name: 'url'
widget: 'string'
- label: '截图'
name: 'screenshot'
widget: 'string'
required: false
- label: '关键词'
name: 'keywords'
widget: 'string'
required: false
- label: '描述'
name: 'description'
widget: 'string'
required: false

保存后记得 Git 推送到Github。

进入你的 Decap CMS

打开你的邮箱,找到那封邀请邮件,右键 Accept the invite 复制链接。

链接一般为 https://xxxxxx.org/#invite_token=xxxxxx,把链接改为 https://xxxxxx.org/admin/#invite_token=xxxxxx,在浏览器中打开 https://xxxxxx.org/admin/#invite_token=xxxxxx。打开后会弹出个 Complete your signup,输入你的密码,点 Sign up,完成注册。

然后你就可以愉快地码文章了。

如果你在本教程中遇到任何问题, 欢迎在下方讨论。

评论