Set Up Decap CMS with Jekyll: A Working Example
Decap CMS (formerly Netlify CMS) adds a browser-based editor to a Jekyll site. The example configures collections for blog posts and authors, handles static pages, and ends with a list of gotchas.
- By
- Brennan Kenneth Brown
- Published
- Reading time
- 2 minutes
- Level
- Intermediate
- You need
- A Jekyll site hosted on Netlify or similar
- Basic YAML
Decap CMS (formerly Netlify CMS) is an open-source content management system that adds a browser-based editor to static site generators like Jekyll. This tutorial sets up Decap CMS with Jekyll using a real-world example: Write Club, a university creative writing club’s website.
What this guide covers
-
Basic Decap CMS setup with Jekyll
-
Configuring collections for blog posts
-
Managing authors with a relation widget
-
Handling static pages
-
Common gotchas
How do I configure the Decap CMS backend for Jekyll?
Create a config.yml file in the admin directory of your Jekyll site:
backend:
name: git-gateway
branch: main
identity_url: "https://writeclub.netlify.app/.netlify/identity"
gateway_url: "https://writeclub.netlify.app/.netlify/git"
login: true
roles: ["admin", "editor"]
media_folder: "assets/images/uploads"
public_folder: "/assets/images/uploads"
This configuration:
-
Uses Git Gateway for authentication
-
Sets up media handling directories (
media_folderandpublic_folderare top-level keys in Decap CMS, not part ofbackend) -
Defines admin and editor roles
How do I configure a blog posts collection?
For blog posts, create a collection that matches Jekyll’s _posts directory structure:
collections:
- name: "posts"
label: "Posts"
folder: "_posts"
create: true
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
fields:
- { label: "Title", name: "title", widget: "string" }
- { label: "Image", name: "image", widget: "image", required: false }
- { label: "Author", name: "author", widget: "relation",
collection: "authors", value_field: "username",
search_fields: ["title", "username"],
display_fields: ["title"] }
- { label: "Date", name: "date", widget: "datetime" }
- { label: "Description", name: "description", widget: "text", required: false }
- { label: "Categories", name: "categories", widget: "list" }
- { label: "Tags", name: "tags", widget: "list", required: false }
- { label: "Hidden", name: "hidden", widget: "boolean", default: false }
- { label: "Body", name: "body", widget: "markdown" }
Note the author field uses a relation widget, which we’ll configure next.
How do I manage authors with a relation widget?
For managing authors, create a collection that maps to Jekyll’s _authors directory. Add it under the same collections: key as the posts collection:
- name: "authors"
label: "Authors"
folder: "_authors"
create: true
slug: "{{slug}}"
fields:
- { label: "Display Name", name: "title", widget: "string" }
- { label: "Username", name: "username", widget: "string" }
- { label: "Default Author", name: "default", widget: "boolean", default: false }
- { label: "Avatar", name: "image", widget: "string" }
- { label: "Bio", name: "bio", widget: "text", required: false }
- { label: "Email", name: "email", widget: "string", required: false }
- { label: "Website", name: "website", widget: "string", required: false }
- { label: "Facebook", name: "facebook", widget: "string", required: false }
- { label: "GitHub", name: "github", widget: "string", required: false }
- { label: "Reddit", name: "reddit", widget: "string", required: false }
- { label: "Instagram", name: "instagram", widget: "string", required: false }
- { label: "LinkedIn", name: "linkedin", widget: "string", required: false }
- { label: "Twitter", name: "twitter", widget: "string", required: false }
- { label: "Biography", name: "body", widget: "markdown" }
This configuration allows for comprehensive author profiles with social media links and biographies.
How do I edit static pages?
For static pages, use a file collection since these are individual files rather than a folder of similar content:
- name: "pages"
label: "Pages"
files:
- name: "about"
label: "About Page"
file: "about.md"
fields:
- { label: "Title", name: "title", widget: "string" }
- { label: "Permalink", name: "permalink", widget: "string" }
- { label: "Sidebar", name: "sidebar", widget: "select",
options: ["none", "left", "right"], default: "none" }
- { label: "Content", name: "body", widget: "markdown" }
- name: "terms"
label: "Terms & Code of Conduct"
file: "terms.md"
fields:
- { label: "Title", name: "title", widget: "string" }
- { label: "Permalink", name: "permalink", widget: "string" }
- { label: "Sidebar", name: "sidebar", widget: "select",
options: ["none", "left", "right"], default: "none" }
- { label: "Content", name: "body", widget: "markdown" }
- name: "events"
label: "Events Page"
file: "events/index.md"
fields:
- { label: "Title", name: "title", widget: "string" }
- { label: "Permalink", name: "permalink", widget: "string" }
- { label: "Sidebar", name: "sidebar", widget: "select",
options: ["none", "left", "right"], default: "none" }
- { label: "Content", name: "body", widget: "markdown" }
Note that static pages can live in different locations—the events page is in a subdirectory while other pages are in the root.
What does this configuration give you?
-
Structured Content: Each content type (posts, authors, pages) has a defined structure that matches Jekyll’s expectations
-
Related Content: Posts can reference authors through the relation widget
-
Flexible Pages: Static pages can have different locations while maintaining consistent structure
-
Optional Fields: Many fields are marked as optional (
required: false) to allow for flexibility -
Media Management: Built-in media handling for images and uploads
What else do I need to set up?
-
Ensure your Jekyll site’s directory structure matches the configuration
-
Set up Netlify Identity for authentication
-
Configure Git Gateway for content management
-
Add the Decap CMS script to your admin page
What are the common gotchas?
A few things to watch out for:
-
File Paths: Ensure all file paths in the configuration match your Jekyll site structure
-
Permalinks: Make sure permalinks in the configuration match your Jekyll configuration
-
Media Handling: Test media uploads to ensure paths are correctly configured
-
Author Relations: Test the author relation widget to ensure it correctly links to posts
Where can I see it running?
This configuration is based on a real-world implementation and can be adapted to your own content types. Write Club is the site it powers.