Supporting Hugo page bundles in Netlify CMS
Update your collections definition with a couple new values and you're good to go
I recently rearranged the blog’s posts file structure to take advantage of Hugo’s Page Bundles feature. Without going into too much detail this reorganization enabled me to bundle post content into self-contained folders. Within these folders is a single index.md file containing the post’s Markdown, as well as an images/ folder into which all of the post’s images reside:
I much prefer this to the blog’s earlier setup that dumped Markdown files and images into two folders and made me find individual image URLs within each document to track which images went with which posts.
Unfortunately when I rearranged the posts I broke my Netlify CMS setup and it stopped recognizing that I had any posts! After some digging around I discovered a “beta feature” called Folder Collections Media and Public Folder. I was pleased to find out that I only needed to define a few new properties on my Netlify CMS config.yml’s
collections property to get it to recognize the new folder structure:
- name: "posts"
# Where to store posts (relative to the project root)
# Support Hugo page bundles that puts index.md and images in folders named by slug
Once the new
public_folder were in place Netlify CMS started working. I even wrote this post in it to make sure everything functioned normally. So far so good!