In the various ways to use data files in Hugo, there are inconsistencies:
data folder: Supports JSON, TOML and YAML
getJSON, getCSV : Adds CSV format but does not support YAML/TOML
transform.Unmarshal: Supports JSON, YAML, TOML and CSV.
There should be consistency in supported file formats.
Update: Since the the issue is closed already:
I was hoping to get consistency. data folder cannot hold a CSV file. There is no getYAML to load a YAML file from disk. It seems that is not desired. That’s ok. Just wanted confirmation.
There is certainly a history here. There is at least one issue about adding remote support in resources.Get which would make getJSON/getCsv superflous, as you could do:
Agreed about resources.Get having http support will get rid of the getJSON like methods.
For the data folder, just like transform.Unmarshal creates an array of arrays in the return value, if there is a CSV file within the data folder, that could convert to the same format within the $.Site.Data object (we can assume commas as separators by default since CSV stands for Comma Separated Values).
More than a feature request, I am looking for clarity on the approach and direction regarding these features. In some sense, the $.Site.Data variable is redundant as we could create a cached partial to read the values and return them. Since the Hugo documentation carries the Data templates section, I am interested in understanding its best use cases.