Question on API implementation

I am building an API around the hugo.

In short I want to get Hugo to generate an HTML Response of a special “partials” only…



that would return me the hugo evaluated results as HTML… if if it has {{ .Site.Data.SiteTitle }} that would be replaced with the actual value and only provide me with the html content…

If anyone could point me which function I should start to look at ?


I’m not sure what you’re building. Is it a CMS? In short, Hugo does not have a (stable) public API to do what you want.


Yes, we are currently building a small CMS to ease Hugo adoption for non technical people.

It is a proof of concept, so far it will only allow to create “static html files”. We hope that we can get a first demo released next week and hope to get good community feedback.

We already have extended the go source code and added an /api (verry badly implementation though, as its only for a PoC).

The partials management would be one of our next implementation. We were only trying to get some informations before we start working with partials as we haven’t looked much into the go code on how feasable that would be.


  • Francis L.

There is a Caddy “simple CMS” plugin you may get some info from.

The basics of what you can do currently is:

But don’t get surprised if the API changes …

Nice thank you for the insights, i’ll look into the Tmpl.Lookup function.

Yeah, I would not be surprise if the API changes.

Anyway my current code isn’t that great at the moment, but I’m very happy with the current result… Too bad it cannot be shared at this point I can’t wait until I can release a pre-beta version of it.

I have been trying to do something really quick… now I have my variable based on the templatelookup, but I am not sure which var I can use for the “2nd field” the “Context”

if err := templ.Execute(b, ??? )

Any inputs? I’m looking at the code didn’t find how to pass a valid context…

I would just say that this was not meant to be used as a “public API”. If you can get it to work for you, great, if not, I would not expect getting the solution to your detailed problems here.

I found a way to pass an existing “Page” context, for my PoC. I aggree its a little bit hackish though.