Ksable' 小屋

ホーム留言板
友達ブログについて

# Posts: 使用 Decap CMS 作为 Hexo 后端以实现在线编辑（保姆级教程）

发表于 2024-08-16 14:35
更新于 2024-08-16 22:21
6281 字
32 min read

kissablecho

kissablecho 的个人博客 / 记录生活，分享技术 / 喜欢二次元和白丝。

128 記事

4 カテゴリー

7 タグ
ホーム
留言板
カテゴリー
タグ
アーカイブ
友達
ブログについて
一些实用的网站
astro-koharu 使用指南
音楽
Posts: N 只小猪 by 网友 Posts: 用 Python 设置 Windows 文件默认打开程序 Posts: 开发了个“笔记管理平台”Posts: H 漫画网站爬虫实战 Posts: Python爬虫 通用的小说下载器 Posts: 一个爬取菜鸟教程网站教程，并保存为本地 MarkDown 文件（Python）Posts: Hexo 主题开发笔记 Posts: 将 Umami Cloud 数据导出迁入到自搭建的 Umami Posts: 使用 Decap CMS 作为 Hexo 后端以实现在线编辑（保姆级教程）Posts: ArtPlayer 播放器的简单使用 Posts: 好看的二次元图片分享 Posts: 转载，为什么我们总是在等别人主动？Posts: Hexo Volantis主题副标题以打字效果输出 Hitokoto Posts: 打字机效果的 Hitokoto（html+css+js）Posts: 网易云音乐歌单批量下载歌曲（python）Posts: Hexo Volantis主题音乐播放器Aplayer适应暗黑模式并能跟随变化 Posts: 本站的壁纸
この投稿は「日本語」では表示できません。元の投稿を表示しています。
静态网站建站成本低、安全、轻量，但最大的缺点就是没有后台，更新网站麻烦。Decap CMS 就能解决这个问题本文将介绍 Decap CMS，并详细讲解 Decap CMS 部署教程。让你能在线更新你的静态网站。注意，本篇教程一气呵成（😂），请紧跟步伐。

## 前言

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

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

> 注意，本篇教程一气呵成（😂），请紧跟步伐。

## Decap CMS 简介

- Decap CMS 官网
- Decap CMS 文档
- Decap CMS 演示
- Github Rope

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`。

    skip_render:
        - 'admin/**/*'

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

    <!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`，粘贴下面的代码。

示例代码

    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_url`、`site_url`、`display_url` 改为你自己的。

    logo_url: /favicon.svg # 你的 logo
    site_url: https://xxxxx.org/ # 网站网址
    display_url: https://xxxxx.org/ # 显示网址

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

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

附上我的代码

    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`，完成注册。

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

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

気に入ったら、コメントを残してね～

日本語
中文 English 日本語

kissablecho

kissablecho 的个人博客 / 记录生活，分享技术 / 喜欢二次元和白丝。

128 記事

4 カテゴリー

7 タグ
ホーム
留言板
カテゴリー
タグ
アーカイブ
友達
ブログについて
一些实用的网站
astro-koharu 使用指南
音楽
Posts: N 只小猪 by 网友 Posts: 用 Python 设置 Windows 文件默认打开程序 Posts: 开发了个“笔记管理平台”Posts: H 漫画网站爬虫实战 Posts: Python爬虫 通用的小说下载器 Posts: 一个爬取菜鸟教程网站教程，并保存为本地 MarkDown 文件（Python）Posts: Hexo 主题开发笔记 Posts: 将 Umami Cloud 数据导出迁入到自搭建的 Umami Posts: 使用 Decap CMS 作为 Hexo 后端以实现在线编辑（保姆级教程）Posts: ArtPlayer 播放器的简单使用 Posts: 好看的二次元图片分享 Posts: 转载，为什么我们总是在等别人主动？Posts: Hexo Volantis主题副标题以打字效果输出 Hitokoto Posts: 打字机效果的 Hitokoto（html+css+js）Posts: 网易云音乐歌单批量下载歌曲（python）Posts: Hexo Volantis主题音乐播放器Aplayer适应暗黑模式并能跟随变化 Posts: 本站的壁纸