bye Ghost, hello Hugo

2 minute read Published:

How to migrate from Ghost to Hugo
Table of Contents

Why

After some server profiling I have discover that the dokku app that was running my blogging platform was consuming around 200MB of RAM.

So I start to do some research and I found Hugo

Hugo is a general-purpose website framework. Technically speaking, Hugo is a static site generator. Unlike other systems which dynamically build a page every time a visitor requests one, Hugo does the building when you create your content. Since websites are viewed far more often than they are edited, Hugo is optimized for website viewing while providing a great writing experience.

How

Installation

The installation is quite easy.

# via repository
$ sudo apt-get install hugo
# then we start the new blog
$ hugo new site blog

# Create new post
$ hugo new post/good-to-great.md
/Users/madacluster/blog/content/post/good-to-great.md created

Now we need to install a theme to finish the installation

$ cd themes
$ git clone https://github.com/dim0627/hugo_theme_robust.git

and finally start the server

$ cd ..
$ hugo server --theme=hugo_theme_robust --buildDrafts

Importing old post

I was using a Ghost instance before, and this platform has the possibility to export old post to a json file. This option is inside the admin menu.

For importing the old post, I have use ghostToHugo. For using it you need to have installed go and run

# Installing
$ go get -u github.com/jbarone/ghostToHugo
# Importing
$ ghostToHugo -p ~/your-path-blog your-export.json

Deploying

For the deployment to my dokku droplet, I did the followings steps:

  • Generate the static file
$ hugo
  • Add a file named .static to the public folder, with that dokku will create a nginx instance serving the static file
$ touch public/.static
  • Init the repo and push
# Init the repo
$ cd public
$ git init
$ git add .
$ git commit -m "pulish blog"
# Add remote
$ git remote add dokku dokku@you-dokku-intance:blog
# Push the files
$ git push dokku master

Conclusion

Now the server is using around 300 Mb less after stopping the Ghost instance and its db.

There are still thing to improve, for example automatize the blog posting.

comments powered by Disqus