Hello I’m looking at Hugo as our go-to static site generator and I’m wondering if there was a way to populate templates with information from JSON files? I am working with an API that sends me posts and page information as JSON and I want to use Hugo to build files from that information and then build/deploy site afterwards.
Hugo can ingest JSON and use that data on existing pages (see here and here); however, Hugo doesn’t currently support creating new pages from a JSON data source. Generally speaking, Hugo requires content files in the content folder for each page.
@newton Did you write that script? I’m currently using jekyll with a node script that pulls data down from a REST API and then using a cron to build the site over and over. Something like this would be ideal and I’d switch.
I’m looking into that too. I just need to figure out some way to build somewhat simple sites based on REST data that isn’t “magic.” I really don’t want to get into big frameworks like Angular if I don’t have to.
We ended up using Gulp but npm scripts could have been better. Also anytime a entry is published our CMS triggers webhook that publishes the content, which eliminates the need for cron jobs.
Nothing I have read in the docs or at any of these links makes it clear how I simply dump some JSON on a page via a template or partial. Any pointers would be appreciated, thanks.