A static site generator for Ghost written in C++

A static site generator for Ghost written in C++

Ghost has gained huge popularity in recent years as a blogging platform and a modern alternative to WordPress. Ghost is completely open-source and can be self-hosted. This website is built on a self hosted Ghost instance running on a docker container on a cloud VPS.

ghost-size0-static is a simple static site generator for Ghost that I wrote in C++ using cURLpp and RapidJSON.

Here is a quick documentation on what the project is about and how to use it.

The idea is to fetch all posts and pages from a Ghost blog using Ghost's API and then parse them to generate a static site.

You can read Ghost's Content API documentation here.

ghost-size0-static is open source and made available under MIT License.

You may use CMake to build it.

How to use ghost-size0-static?

ghost-size0-static has three parts. The first part fetch_from_ghost uses libcurlpp to make requests to the content API and fetch the JSON data containing the posts and pages on a blog.

It may be ran as

fetch_from_ghost <Your Ghost Blog Url> <Content API Key>

Remember that you need to first generate a Content API Key from the Ghost admin page by going to the Integrations section in settings and then clicking on "Add custom integration".

The second part is to parse the JSON data and generate the pages and posts in plain html (the programs parse_pages and parse_posts have been supplied for this).

Finally you can run the Python script genstatic.py and generate the index.html file with links to the other html pages that you generated in the previous step.

A demo of the project is available at https://light.ashik.se (I ran ghost-size0-static on this very blog and generated a static website which I pushed to a lighttpd server).