Database connection to content in Hugo Framework

What’s the best way to bring in database content into Hugo’s framework? Anyone have any proof of work on the topic? If Php, where does the includes data go. I.e. PDO connections…

Cheers mates,

You’d have to dump your content to a format Hugo can consume, like .yaml, .json, .xml, to the data directory.

1 Like

There no built-in solution yet, but there is a workaround explained here: Toward using a Headless CMS with Hugo: Building Pages from an API | The New Dynamic

Also I built a Hugo module which abstracts the logic described in the article and mimics the UX planned for the upcoming built-in Hugo feature: GitHub - theNewDynamic/hugo-module-tnd-data

I’d still recommend reading the article before diving into the Module.

Let me know if this helps, any feedbacks are welcome.

1 Like

@nternetinspired @regis, Thanks for your feedback. Thinking out loud, but if I run a job to export from my AWS Database to an S3 bucket as a JSON API and have Hugo unpack the data into the website. Do we think there might be potential for a real-time connection there somehow? just a thought. ~Cheers Mates

Not sure what you mean by that, are you thinking server side rendering?

The solution I advertised for would read your API during build-time and publish pages from that.

@regis yes, I saw your solution. I will need to invoke a test on your solution in my instance. yes, I was thing server-side rendering. Do you have a working proof that is up and running that I can take a look at?
~cheers mate

I don’t have anything public you can take a look at no except for the repo shared in the blog post.

You’ll have to test it for yourself in your environment (never tested this with a very slow API for ex), but I’m using it in production and did not notice any problem whatsoever.

1 Like