LoginSignup
4
2

More than 3 years have passed since last update.

Netlify CMSのインストール

Last updated at Posted at 2019-07-02

ルート配下に admin ファイルを作成しその中に index.htmlconfig.ymlを作成するだけでインストールすることができる。

index.html
<!doctype html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Content Manager</title>
    <style type="text/css">
        .SplitPane.css-gwx01d-StyledSplitPane-dropMain-card-splitPane.e1pxf6c40.vertical  {
            display: flex;
            flex-direction: column !important;
            overflow: auto !important;
        }
        .Pane.vertical.Pane1{
            width: 100% !important;
        }
    </style>
</head>
<body>
<!-- Include the script that builds the page and powers Netlify CMS -->
<script src="https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js"></script>
<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
<script>
    if (window.netlifyIdentity) {
        window.netlifyIdentity.on("init", user => {
            if (!user) {
                window.netlifyIdentity.on("login", () => {
                    document.location.href = "/admin/";
                });
            }
        });
    }
</script>
</body>
</html>
config.yml
backend:
  name: git-gateway
  repo: [git-repo]   #githubのリポジトリ
  branch: [ブランチ]  # Branch to update (optional; defaults to master)

publish_mode: editorial_workflow

media_folder: "static/images/uploads" #アップロードされたファイルを保存するフォルダパス
public_folder: "/images/uploads" #アップロードされたファイルがアクセスされるフォルダパス
collections:
  - name: "post"
    label: "Post"
    folder: "content/post"
    create: true
    slug: "{{slug}}"
    fields: # 管理画面に追加したいフォームを追加していく
      - {label: "Title", name: "title", widget: "string"}
      - {label: "Description", name: "description", widget: "text", required: false}
      - {label: "Featured Image", name: "featuredImage", widget: "image", required: false}
      - {label: "Featured Image Description", name: "featuredImageDescription", widget: "text", required: false}
      - {label: "Publish Date", name: "date", widget: "datetime"}
      - {label: "Category", name: "categories", widget: "text", required: false}
      - {label: "Tag", name: "tag", widget: "text", required: false}
      - {label: "Body", name: "body", widget: "markdown"}
4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2