I’d been using blogger for a while now, but found that the last couple of years had not bothered making and publishing notes to my blog as I normally did. Blogger also has has some weird formatting issues (because I cannot HTML). So I decided to migrate to a static blog. Before proceeding I decided to document a number fo requirements I would like addressed.
Requirements
- Migrate to static web pages instead of CMS
- Easily update blog with short posts (to force myself to post regularly).
- Easily migrate from blogger.
- No database back end
- Supports github or similar markdown
- Supports themes/templates/CSS
Security Requirements
- Confidentiality - no, I don’t care if others read my notes, its a blog, will
- be publically accessible
- Integrity - yes
- Availability -yes
I Googles for a number of possible solutions and kept coming up with more and more of these static blog generators, until I finally came across https://www.staticgen.com/, and gave up. I decided to evaluate the short list I had come up with against some of these requirements.
Possible Solutions | Language | Markdown | Themes |
---|---|---|---|
Hexo | Javascript | Yes | EJS/Pug |
Hugo | GoLang | Blackfriday | Go/HTML |
Jekyllrb | Ruby | Yes | Liquid |
Lektor | Python | Jinja2 | |
Middleman | Ruby | Kramdown | ERB/Tilt |
Nikola | Python | Yes | Jinja2 |
Pelican | Python | Yes | Jinja2 |
After a brief consultation with Yaleman I decided to go with Hugo. I’ve documented the steps below for my reference. These instructions are for a Windows machines, as most of the documentation available described how to setup the environment for Linux based systems.
These instructions assume that Python is already installed on the Windows machine.
- Download Hugo from https://github.com/gohugoio/hugo/releases
- Extract the zip file and save the contents to
C:\Hugo
- Update PATH system environment variable to include the bin location, e.g.
set PATH=%PATH%;C:\Hugo\bin\
- Download blogger_to_hugo
https://bitbucket.org/petraszd/blogger-to-hugo/downloads/
and extract zip file - Change to the extracted directory e.g.
cd petraszd-blogger-to-hugo-d6de3e66d8cf
- Install blogger_to_hugo
pip install blogger_to_hugo
- Download pandoc e.g.
https://github.com/jgm/pandoc/releases/download/2.1.3/pandoc-2.1.3-windows.msi
- Install pandoc by running
msiexec -i pandoc-2.1.3-windows.msi
- Update PATH system environment variable to include the Pandoc location, e.g.
set PATH=%PATH%;C:\Users\nkush\AppData\Local\Pandoc\
- Log into blogger and navigate to Settings -> Other -> Import & back up -> Back up content, save the XML to disk, e.g.
C:\Temp\blog-0402502018.xml
- Convert to markdown
python blogger_to_hugo.py C:\Temp\blog-04-25-2018.xml C:\Temp\blog
- Create a github page, in my case it was https://kushfj.github.io/, this is done by creating a repository with the name
[username].github.io
, where [username] is your github username - Within the hugo site directory, remove the public directory e.g.
rmdir /s ./public
- Create a submodule
git submodule add -b master https://kushfj:[api-token]@github.com/kushfj/kushfj.github.io public
- Copy the migrated files into the content/posts directory
- Run hugo command to build the site in the hugo contect e.g.
hugo
- Change to the public directory which contains the generated output e.g.
cd public
- Add the generated files to the repository e.g.
git add .
- Commit the files to the repository with an initial comment e.g.
git commit -m "initial migrated version"
- Push the public folder into github to publish the site e.g.
git push origin master
To add a new blog post
- Create a new content file e.g.
hugo new posts/2018-04-25-new-blog-post.md
- Edit the file to create the actual content in markdown
- Run live reload server to test the post
hugo server
- Connect using your web browser to the localhost and review the post
The migrated blog posts have several formatting issues, which I will leave as it is, as there is little or no benefit it reformatting the old posts.