Render data with chart.js or Google charts - AKA access Hugo's data from JavaScript

I want to render a nice chart with either Chart.js (or Google Charts) using data provided into a json file.

More generally, consider the example in Hugo’s docs: how can I loop over all {{ .Data.jazz.bass}} and use all entries in the list discography as variables into a JavaScript?

Somewhat similar to this old post. I tried all solutions mentioned there, but I had no success.

I will chime in with the short version of this here:

  • Use the js.Build function
  • For small data sets (e.g. config options), pass it in the params option
  • For bigger data sets, use JavaScript’s fetch.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.