Skip to content

Hugo Integration Guide ​

This guide provides resources and information for integrating Sveltia CMS with Hugo, a popular static site generator.

Starter Templates ​

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

Disclaimer

These third-party resources are not necessarily reviewed by the Sveltia CMS team. We are not responsible for their maintenance or support. Please contact the respective authors for any issues or questions.

Examples ​

See real-world examples of Hugo 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 Hugo.

Setup ​

Adding the Admin Page ​

Hugo serves static files from the static folder. Create static/admin/index.html and static/admin/config.yml as described in the Getting Started guide. The admin page is then available at /admin/ on the development server started with hugo server as well as on the built site.

Configuration ​

Hugo stores content in the content folder, and each subfolder is a section, such as content/posts. The following example manages the posts section, storing each post as a page bundle with its images in the same folder:

yaml
media_folder: static/images
public_folder: /images
collections:
  - name: posts
    label: Posts
    folder: content/posts
    path: '{{slug}}/index'
    media_folder: ''
    public_folder: ''
    create: true
    fields:
      - { name: title, label: Title }
      - { name: date, label: Date, widget: datetime }
      - { name: draft, label: Draft, widget: boolean, default: true }
      - { name: description, label: Description, required: false }
      - { name: tags, label: Tags, widget: list, required: false }
      - { name: body, label: Body, widget: markdown }

Some notes on this configuration:

  • The path option saves a post as content/posts/my-post/index.md, and the empty media_folder and public_folder options store its images in the same folder. See Using Entry-Relative Folders for details. If you prefer single files like content/posts/my-post.md, remove these three options, and images are saved in the static/images folder defined at the top level instead.
  • Posts with draft: true are not published unless Hugo runs with the --buildDrafts option. The default value above makes new posts drafts, so editors need to turn the option off to publish them. Alternatively, use the Editorial Workflow to review posts before they’re published.
  • Hugo supports YAML, TOML and JSON front matter. Sveltia CMS detects the format of existing files automatically and saves new files with YAML front matter by default. Set the collection’s format option to toml-frontmatter if your site uses TOML.
  • Hugo’s _index.md files, which hold the content of section list pages, can be managed along with the regular entries using the index_file collection option.

Support for Hugo ​

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