Using Ghost as a headless CMS with Hugo


I’m currently trying to figure out the best approach to use Ghost as a headless CMS to render a static page via Hugo.

So far I found Data Templates, which allow to pull content from a given URL. The following snippet allows me to render a list of all posts:

    {{ $urlPre := "https://<hostname>" }}
    {{ $urlKey := "/?key=<api-key>" }}
    {{ $json := getJSON $urlPre "/ghost/api/v3/content/posts" $urlKey }}

    {{ range $json.posts | first 10 }}
     <li><a href="{{ .url }}" target="_blank">{{ .title }}</a></li>
    {{ end }}

But what is the best approach to render the actual posts? Is there any chance to “configure” the content of the Hugo Posts? Currently I’m just linking to the Ghost posts, which is not exactly what I intended :wink:

Any hints appreciated!

Kind regards,

1 Like

It’s coming: :slight_smile:


Thats good news, thank you!
Though I hoped it is already possible - reading about all the “JAM”-Buzz lead me to this assumption^^’

Are there any news on this and any examples on how to set up Ghost as a headless CMS for HUGO?


There are no news.

Hugo still does not support generating content pages from data.

With that said if Ghost gives you the option to output content as a JSON array then the simplest way that I know would be to use JQ to split it into multiple markdown files. You can keep the JSON format within the generated files as it will be their front matter.

A single JSON object surrounded by ‘ { ’ and ‘ } ’, followed by a new line is acceptable front matter format by Hugo.

There have also been other techniques posted in the forum regarding splitting a JSON into pages.

Also I’m archiving this old topic. I suggest that you track the GitHub issue that was posted above for future developments or if you want to discuss this feature further then please open a new forum topic. Perhaps others have other techniques to share.