Getting JSON files from Google drive

This is an 11 month old thread and not exactly on topic.

However I have spent some time looking at various APIs this week, including the Google Drive one.

In the latest iteration (v3) of the Google Drive API, there is no way for anyone to access the contents of a public JSON file without authentication.

An API key is required (you can get one here) and then one can use the following endpoint:

https://www.googleapis.com/drive/v3/files/<file-ID>?alt=media&key=<API key>

ref

By passing the above endpoint to Hugo’s getJSON function it is possible to access the contents of a public JSON from Google Drive and process them in a project’s templates, without using any third party commercial service.

Also if one knows how to automate things, it is very much possible to use a Google Sheet as the back end for a Hugo project (no need for the complicated Google Drive CMS).

There is a pretty useful extension to output a Google sheet to JSON in Drive available over here. I tested it and it generates valid JSON, including nested JSON arrays and it supports overwriting the same file in Drive.

So yes. It is possible to do some amazing things with Hugo for free.

2 Likes