Read json/yaml/toml file inside a page bundle


Is there a way to read the content of a data file placed outside the /data directory?

Im organizing my project using the page bundles and would be awesome have data files in the same directory as the other resources as images or md files.

Thank you.

As far as i know, it’s only possible with JSON and CSV at the moment. See data-driven content docs :slight_smile:


That’s specific to getJSON and getCSV functions. But you can have JSON/YAML/TOML data files in the site’s data/ dir and have it read using (assuming the file base name is foo) – recent example.

@cmal Sorry, I misunderstood the question… read too fast.

The OP said:

de /data directory?

So I was quick on the trigger to assume that this was a question about multi-language site (because “de”) and data/.

I now see that you meant to say that you can read only JSON and CSV data files from outside data/.

thank you guys! it works. Shame on me for not reading the docs properly.

if it helps someone, this post have helped me with an error after get “getJSON” working

Seriously hugo and this community are amazing, thanks to all the community and the devs for your work.