Access package.json from within Hugo

The data-driven feature, though powerful, doesn’t seem to support harnessing local data files such as package.json. Is there a way to access and iterate over it in a Hugo/Go template?

It depends what your definition of “local files”, but:

  • readFile
  • getJSON, getCSV

Should get you what you want, but these are restricted to the Hugo project.

Ah, so getJSON doesn’t just take URLs, then? Cool.

I guess I just supply a relative path like '../../package.json' ?

See the Hugo documentation.