As Octopress is dead and hasn’t been updated for 3 years I’ve and I wanted to write some blog posts I’ve decided to migrate my static site generation to hugo.
I’d like to share some of the things I’ve done and learned during this migration.
Steps
Setup project with hugo
In order to get started I’ve followed the quick start guide.
- Install hugo using a
*.deb
file from the GitHub releases page. - Create a new hugo project
hugo new site
- Choose a theme. And here I was lucky as parsiya did the great work of porting the Octopress theme
I’ve been using to hugo. So the design of the blog didn’t change (that much). Installation of the theme was straight forward:
git submodule add https://github.com/parsiya/Hugo-Octopress.git themes/octopress
and settingtheme = "octopress"
inconfig.toml
. - Create a new blog post to check the syntax of the resulting markdown file and write this blog post.
hugo new posts/migrated-to-hugo.md
Move contents
- Copy over all the static content from the octopress project. Here I had mainly images and some static files required for Google and Bing webmaster tools.
- Copying the posts didn’t yield the expected result. Most of the posts didn’t have a date after migration. This was the result of migrating from wordpress
to Octopress and now to hugo. After the first migration the blogpsots had a date in their file names but didn’t have a
date
-tag in the header of the markdown file. Thus hugo couldn’t find any date. In order to take over the date from the filename to the file I’ve written a little shell script:
#!/bin/bash
cd content/post
for f in *-*-*-*.*; do
d="date: ${f:0:4}-${f:5:2}-${f:8:2}T00:00:00+01:00"
echo "$d - $f"
sed "2i$d" "$f" > "a$f"
done
This processed files like 2011-06-22-debian-zeitzone-anpassen.md
, extracted the date from the filename and inserted a date:
tag with the
corresponding date as the second line.