Headless Bundles as Data

Lately I’ve been experimenting with using Hugo’s headless bundles to store data as markdown files instead of using the data/ directory. This strategy plays really well with Forestry’s CMS because you can define a template for your front matter fields, as well as create dropdown fields populated by the pages in a certain section.

I wrote an article about doing this and included a naive example of it in action: Keeping Content DRY: Data Relationships in Hugo.

This is definitely something I plan on working with more in the future, as I think there are some cool possibilities here.

Has anyone else tried this? I’d love to know what you think!

Disclaimer: I work for Forestry.io


Headless bundles are great, but I wish there was an easy way to loop through them on a single page.

That’s why the approach discussed in @dwalkr’s article is interesting. Rather than create one headless bundles for each data entry, your create just one bundle containing your entries as .md files Page Resources. Then, all you have to do when you need to iterate over this data is .GetPage this one headless bundle and loop on its resources.


@dwalkr alkr your code doesn’t work on my local site. So I fixed it a bit

{{ with .Site.GetPage "venues" }}
    {{ with (index (.Resources.Match (string $.Params.venue)) 0) }}
    <h3>{{ .Title }}: {{ .Params.address }}</h3>
        {{ .Content }}
    {{ end }}
{{ end }} 

btw nice article. It is exactly what I need for my site.

thank you very much


I’ve been racking my brain for a while on how to create post authors for use with forestry.io. This worked perfectly in conjunction with forestry’s sortable list field. Bonus I can assign/sort multiple authors per post.


1 Like

My sincere apologies for reviving this dead thread but apart from the benefit from the Forestry aspect of configurable front matter templates, what benefit is there to having a headless bundle of markdown files each with information as opposed to having a single venues.toml in the /data/ folder?