Migrate from Pelican and WordPress to Hugo

By Yong-Siang Shih / Sun 22 July 2018 / In categories Notes

Hugo, Pelican

Translations: ZH

Back in 2014, I migrated my blogs to Pelican. While there were many static site generators to choose from, the reason I chose Pelican was twofold. Firstly, I was influenced by my friend who used Pelican. Secondly, I had been using Python for some time and therefore I liked the fact that Pelican was developed with Python.

Years have passed. It appears that my friend is no longer using Pelican for her blog. In addition, the development on Pelican is no longer as active as before. Moreover, Pelican gets slower as the number of articles grows. Therefore, I start to think about migrating to a new static site generator.

I decided to use Hugo. It’s fast, actively developed, and it’s built with Go, which I also use from time to time.

Because I want to keep the theme of City of Wings, I spent most of my time porting Nest to Den. Once the theme is ported, the remaining task is easy. The Markdown files do not require too much modification. Mostly I only modified the {filename} URLs for Pelican, and the representation of code blocks. Because it’s a little bit troublesome to parse Markdown, I simply used Vim commands to modify each file.

For An Island, it’s a lot more complicated. To migrate from WordPress to Hugo, I built a small tool wp2hugo to download all the images in my articles and parse exported XML files and convert them to Markdown. I also manually modify WordPress Shortcodes to complete the migration.

During the migration, I also updated the legacy URL structure of City of Wings that came from Blogger. In order to keep the original URLs working I used Aliases capability of Hugo to generate redirects. Finally, I also enabled multilingual support for both City of Wings and An Island.

The final result:

Notebook
Yong-Siang Shih

Author

Yong-Siang Shih

Software Engineer, Machine Learning Scientist, Open Source Enthusiast. Worked at Appier building machine learning systems, and interned at Google, IBM, and Microsoft as software engineering intern. Love to learn and build things.* Follow me on GitHub

Load Disqus Comments