Creation of single entries from JSON data file

I’m trying to make a site which contains video tutorials under an authentication / permission based system. It uses Vimeo + Firebase for auth and video tutorial data. The rest is static in Hugo.

In essence its a very static site that has a single collection (video tutorials) with lots of entries coming from a JSON file.

The problem is I want to create single entries for each tutorial so that I can make a Hugo driven static file per tutorial and also get all of the template language goodness to create archives of tags, authors and many other key:value pairs.

As far as I can see the JSON URL ingestion and indexing is only available on a per page basis so there is no way to generate numerous file entries from JSON.

I know this could be done with a script if it was a one off action but as I add new entries, chopping up and rendering the JSON > MD seems tedious and I would also have to deal with all of the old files.

Does anybody have any workarounds or suggestions of how to architect this solution with Hugo?

Thanks

Dan

1 Like

So my use-case is different for yours, because I am creating single entries for my videos because I wanted to be able to take advantage of having them as a part of the site. I also needed to display those videos in aggregate organized around “playlists,” which, in my site, are a separate section, each playlist with its own page. So I created a page level custom output type of JSON for the videos and output essential information, then on each playlist page I use a query parameter to pull in that data and pass it to the Youtube API to create a video player. It’s a work in progress, but here’s an example:

https://www.retroreport.org/video/the-long-strange-trip-of-lsd/index.json
https://www.retroreport.org/playlist/most-popular/?id=video%2Fthe-long-strange-trip-of-lsd
(caution, the video will play automatically, with sound. Users coming to this page will have typically hit a “play” button).

Happy to chat about it more, though, like I said, I see my use-case seems quite different than yours.

Thanks Bud,

As you say, your use case is different, in fact almost the inverse of mine.

Having now read what I think is every article about this online (not many out there) I cannot see that there is a way at present to render single items out of JSON (or other ) data at present but boy would it make a superb feature!

Best wishes,

Dan

Remarkably, I found the solution to this for anyone interested although only in Jekyll and not Hugo thanks to the Jekyll plugin ecosystem.

This article explains how somebody pulls a JSON file hourly from The Guardian Newspaper (UK) and then shows individual articles using https://github.com/avillafiorita/jekyll-datapage_gen plugin.

It’s clever stuff and this guy has a whole load of other great Jekyll articles.

Hope that helps someone else with the same conundrum

Dan

1 Like

I am trying to do the same thing as @danfascia suggested. I guess still Hugo does not support this kind of functionality from within.