over to hugo

Have been using octopress for a while now, but one thing i dont like is it’s reliance on ruby and time it takes to regenerate. Found that hugo is much better at these. Earlier site regeneration used to take ~5 minutes now happens in ~.2 seconds! Thus came the attraction of moving over- but as i found i am not the first to do so. I have read various posts and these are my steps to port it over:

The best part is no more rubydevkit and gem/bundler installs, what a big relief


Since hugo is a different system as compared to octopress/jekyll- you can’t just drop replace it as it is. Hugo has a handy import command to translate markdown files:

hugo import jekyll <octopressblog-dir\source> <new-hugodir-temp>

once you have that create a new site in hugo (I found this is much easier than migrating earlier site) and copy your md files to content\post\blog directory.

hugo new site blogsite

D:\blog\hugo\blogsite>ls -l
total 1
drwxrwxrwx   1 user     group           0 Nov 27 17:01 archetypes
-rw-rw-rw-   1 user     group         107 Nov 27 17:01 config.toml
drwxrwxrwx   1 user     group           0 Nov 27 17:01 content
drwxrwxrwx   1 user     group           0 Nov 27 17:01 data
drwxrwxrwx   1 user     group           0 Nov 27 17:01 layouts
drwxrwxrwx   1 user     group           0 Nov 27 17:01 static
drwxrwxrwx   1 user     group           0 Nov 27 17:01 themes

config.toml file is your earlier _config.yaml file. hugo does look for config.yaml but i thought it is much better if i populate it fresh. Here is some good information on how to configure hugo

Now one of the most important constraints i have is to make this site compabitle with what i already have with octopress. Thus permalinks are going to be painful, which they were. I added these two lines in config.toml.

canonifyurls = false

Once i had this things were working good, now comes the part about images/wp-content (quite a bit of baggage to carry from octopress and wordpress), both the directories goes to you blog-root directory. This is one of the images from really old post

An image properly linked from wordpress days over to hugo

An image properly linked from wordpress days over to hugo

Now that most of the stuff is located at proper place- now comes theme. Wanted something simple, responsive but useful- found a hugo port of beautiful-jekyll theme and tweaked it to my needs here. The good part is it has support for archives as well as top navigator on the page (so i can put my disclaimer page right up there :) )

generating site

generating site is pretty simple- ensure you have created a public directory in your blog-root, run hugo command without any params, assuming you have specified which theme to be used in config.toml this will populate your site.

over to github

before pushing to github ensure that you have ignored public directory from your sources, it’s un-neccessary stuff to track in your source.

//  do this if you are not in blog-root
cd <blog-root>
git init
echo "public/" >> .gitignore

//  now over to public, init git and add remote origin
cd public
git init
git remote add origin [email protected]:<github-username>/blog.git

git checkout -b master
//  Switched to a new branch 'gh-pages'

git add --all
git commit -m "over to hugo"
git push -f origin master

This quickstart tutorial is pretty handy with details about generating site and pushing over to github. That’s all for now.