Hugo noob here. I need to fetch data from a json file stored in the data directory. Say my file is departments.json and has content like
[
{
"DepartmentText": "Quality Assurance",
"DepartmentAbbr": "QA",
"HasSOP": true,
"SOPAbbr": "QA",
"DepartmentIcon": "material/check-decagram"
},
{
"DepartmentText": "Quality Control",
"DepartmentAbbr": "QC",
"HasSOP": true,
"SOPAbbr": "QC",
"DepartmentIcon": "material/flask-outline"
},
{
"DepartmentText": "Quality Microbiology",
"DepartmentAbbr": "QM",
"HasSOP": true,
"SOPAbbr": "QM",
"DepartmentIcon": "material/microscope"
}
]
On a random markdown file, I am trying to access the content with the following
{{ range .Site.Data.departments }}
- {{ .DepartmentText }}
{{ end }}
Exactly like this…
But I am getting this on my site (with hugo server)
Should I be directly putting the code on markdown file or should I put this in the layouts/partials or something?