Using Netlify CMS with Hugo

Mar 22, 2017 23:48 · 260 words · 2 minutes read netlify cms hugo

If you’re using Hugo to generate your static site and want to use Netlify CMS to edit your content, here are some tips to help you get started.

You’ll have to use YAML front matter in your Markdown documents since Netlify CMS doesn’t currently support TOML front matter.

When creating your config.yml make sure to include at least one collection or the CMS will fail to load.

Here’s an example config.yml which supports a single “post” collection to allow creating and editing content in content/post/:

# Save changes to GitHub
  name: github
  repo: user/repo
  branch: master

# Use the Editorial workflow -
publish_mode: editorial_workflow

# Save image uploads to /img/uploads -
media_folder: "static/img/uploads"
public_folder: "/img/uploads"

# Collections
collections: # A list of collections the CMS should be able to edit
  # Used in routes, ie.: /admin/collections/:slug/edit
  - name: "post"
    # Used in the UI, ie.: "New Post"
    label: "Post"
    # The path to the folder where the documents are stored
    folder: "content/post"
    # Allow users to create new documents in this collection
    create: true
    # Filename template e.g.
    slug: "{{slug}}"
    # The fields each document in this collection have
      - {label: "Title", name: "title", widget: "string", tagname: "h1"}
      # Use required: false instead of optional: true -
      - {label: "Description", name: "description", widget: "text", required: false}
      - {label: "Body", name: "body", widget: "markdown"}
      - {label: "Date", name: "date", widget: "datetime"}
# Does not currently work, see
#      - {label: "Tags", name: "tags", widget: "list"}
#      - {label: "Categories", name: "categories", widget: "list"}

© Copyright 2018 Joseph Earl