Skip to content
Sveltia CMS
Esc
↑↓navigate↵open⌘Jpreview
On this page

Eleventy Integration Guide

Learn how to integrate Sveltia CMS with Eleventy, including passthrough copy, blog collection configuration, starter templates and real-world examples.

This guide provides resources and information for integrating Sveltia CMS with Eleventy (11ty), a simple and flexible static site generator.

Starter Templates

Here are some starter templates built by the community using Eleventy:

Examples

See real-world examples of Eleventy integrations in our showcase. Most of the listed sites include links to their source code, so you can explore how they implemented Sveltia CMS with Eleventy.

Setup

Adding the Admin Page

Eleventy doesn’t have a static files folder. It processes template files, including HTML, in the input folder, which is the project root by default. Other files are ignored.

Create admin/index.html and admin/config.yml as described in the Getting Started guide. Then add a passthrough file copy to your Eleventy configuration file so that both files are copied to the output folder as is:

export default function (eleventyConfig) {
  eleventyConfig.addPassthroughCopy('admin');
}

Without this, config.yml is not copied at all, and the CMS fails to load the configuration. If your input folder is not the project root, such as src, put the admin folder in it and use addPassthroughCopy('src/admin') instead. The admin page is then available at /admin/ on the development server started with eleventy --serve as well as on the built site.

Configuration

Eleventy doesn’t have a fixed content folder, so blog posts can be stored in any folder in the input folder, such as posts. The following example manages Markdown posts in the posts folder:

media_folder: images
public_folder: /images
collections:
  - name: posts
    label: Posts
    folder: posts
    create: true
    fields:
      - { name: title, label: Title }
      - { name: date, label: Date, widget: datetime }
      - { name: tags, label: Tags, widget: list, required: false }
      - { name: body, label: Body, widget: markdown }

Some notes on this configuration:

  • The images media folder also needs a passthrough file copy, such as addPassthroughCopy('images'), to be included in the output.
  • The layout and the posts tag shared by all posts are usually defined in a directory data file like posts/posts.json instead of the front matter of each post. Eleventy merges the tags in the front matter with the ones in the data file, so editors only need to add extra tags. The data file itself can be managed in the same collection, as explained below.
  • Eleventy uses the filename as the URL of a post by default, such as /posts/hello-world/. Each post can override it with a permalink property, which can be added as a String field if needed, or filled in by the CMS.

Support for Eleventy

We have implemented specific features to enhance the integration of Sveltia CMS with Eleventy:

Was this page helpful?