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.
- 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
- 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.
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
- Update PATH system environment variable to include the bin location, e.g.
- Download blogger_to_hugo
https://bitbucket.org/petraszd/blogger-to-hugo/downloads/and extract zip file
- Change to the extracted directory e.g.
- Install blogger_to_hugo
pip install blogger_to_hugo
- Download pandoc e.g.
- Install pandoc by running
msiexec -i pandoc-2.1.3-windows.msi
- Update PATH system environment variable to include the Pandoc location, e.g.
- Log into blogger and navigate to Settings -> Other -> Import & back up -> Back up content, save the XML to disk, e.g.
- 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.
- Change to the public directory which contains the generated output e.g.
- 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
- 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.