Using gomplate to generate pages from data sources


I did a search on the forum for whether someone else has used gomplate with Hugo but found no results, so I thought I’d write something up.

While waiting for this issue to resolve, I stumbled across gomplate, which is a template renderer that supports several data sources. It uses the same syntax that Hugo does, which means if you can use Hugo, you can pretty much use gomplate as well.

So, what is it?

In my specific example, I use gomplate to generate markdown files from a JSON endpoint. I feed it a template so it knows how to map json to frontmatter keys, for example.

An example workflow would be:

  1. Run gomplate to populate content/posts/
  2. Run hugo to generate site

See site demo deployed to netlify:

See sample repo:

  • navigate to hugo-demo for Hugo site demo
  • additional examples using local csv and json files can be found under gomplate-demo

See gomplate docs:


I just stumbled upon gomplate last night, in searching for a project scaffolding tool to meet my particular (minimalist) needs (I landed on cookiecutter). I thought: hey, I should read up on how the data sources stuff is coming along, and if I ought to drop this in Tools/libraries that can drive new Hugo features:slight_smile:


Ah! That thread is what was wiggling at the back of my mind as I was typing this up last night. :bulb:

1 Like