New Blog


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.

  1. Download Hugo from https://github.com/gohugoio/hugo/releases
  2. Extract the zip file and save the contents to C:\Hugo
  3. Update PATH system environment variable to include the bin location, e.g. set PATH=%PATH%;C:\Hugo\bin\
  4. Download blogger_to_hugo https://bitbucket.org/petraszd/blogger-to-hugo/downloads/ and extract zip file
  5. Change to the extracted directory e.g. cd petraszd-blogger-to-hugo-d6de3e66d8cf
  6. Install blogger_to_hugo pip install blogger_to_hugo
  7. Download pandoc e.g. https://github.com/jgm/pandoc/releases/download/2.1.3/pandoc-2.1.3-windows.msi
  8. Install pandoc by running msiexec -i pandoc-2.1.3-windows.msi
  9. Update PATH system environment variable to include the Pandoc location, e.g. set PATH=%PATH%;C:\Users\nkush\AppData\Local\Pandoc\
  10. 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
  11. Convert to markdown python blogger_to_hugo.py C:\Temp\blog-04-25-2018.xml C:\Temp\blog
  12. 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
  13. Within the hugo site directory, remove the public directory e.g. rmdir /s ./public
  14. Create a submodule git submodule add -b master https://kushfj:[api-token]@github.com/kushfj/kushfj.github.io public
  15. Copy the migrated files into the content/posts directory
  16. Run hugo command to build the site in the hugo contect e.g. hugo
  17. Change to the public directory which contains the generated output e.g. cd public
  18. Add the generated files to the repository e.g. git add .
  19. Commit the files to the repository with an initial comment e.g. git commit -m "initial migrated version"
  20. Push the public folder into github to publish the site e.g. git push origin master

To add a new blog post

  1. Create a new content file e.g. hugo new posts/2018-04-25-new-blog-post.md
  2. Edit the file to create the actual content in markdown
  3. Run live reload server to test the post hugo server
  4. 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.