I’m quite new to go and am currently tinkering with Hugo. I have an idea for a project which would require me to access data from a database. I’ve seen this possibility mentioned in Issue #450.
How should I tackle that best? Write an export script to write the data into a yaml (which somehow looks hacky and error prone to me) and then iterate over it or should I try to find a solution to access my DB directly? Would be grateful for every hint or piece of advice.
Not sure of a good answer, but I wanted something a little similar, which was to export data from a Drupal database to Hugo text files. I wrote a tool to do it. https://bitbucket.org/rickb777/drupal2hugo
It currently ignores taxonomies, which is an important omission.
There’s an open issue about getting some “data models” support in Hugo, and one could imagine that being expanded to a database – but this is still at site build time.
If you want a more dynamic db integration, I would go the JavaScript and Rest route (maybe Firebase or similar?).
Hugo will support static data models soon… These are just YAML/JSON/TOML files in the site source directory. I could eventually see direct DB access, but it won’t be soon. There’s not much motivation for doing so since the destination isn’t dynamic, but static as @bjornerik said.
Data in data/jazz/bass/jacopastorius.toml is accessible through Site, so every node can access it through that map in a template?
Is there a way to pass that map to a template? Could I, for example, assign it to Scratch and then use it in a template? The use case is “user wants to pass datasets for different artists to that template” and the artists are stored in separate files.