Data files in the page bundle

The concept of the global data folder does not work well with the page bundle concept. There should be a way to have data folders specific to page bundles that can override the global data variables just like assets already do.

I would love to put a yaml file in the page bundle and access it in the page. Is there a way to already do this per page?

That way we could carve out things like the sidebar into a separate files without resorting to cramming it in the front matter. Headless pages with special names can be used as an alternative but they bring their own burden with them being parallel to the page rather than components.

I have a nagging feeling that I forgot to document this (did I, @regis ?) … But you can do:

{{ $data := .Resources.Get "mydata.yaml" | transform.Unmarshal }} 
1 Like

I did not find this in the documentation. That looks really powerful.

Update. Ahh I see

It is just in function docs. Not in the other places like the data documentation.

1 Like

On vacation hence the slow response but we did not document the many possibilities opened by the transform methods no.