This blog was born in a college BBS, later migrated to MSN Spaces, later based on Wordpress. Now it’s powered by Jekyll, deployed on GitHub Pages.
I wrote this on my About page. In this post I am going to write in details about the whole history, in reverse chronological order. Starting a blog is easier but keeping it alive is extremely hard. You may find some tips if you happen to be stuck in one of the scenarios.
Migrating Jekyll Theme from Minima to Minimal Mistakes (2020)
This was the most recent, and least destructive migration of the blog. I chose to switch my the me, from Minima, the default Jekyll theme when you run
jekyll new your-awesome-blog, to Minimal Mistakes, which is beautiful and becomes very impactful in recent years.
The migration mainly involves 2 parts: configurations and contents.
The site configurations
Including the layout, navigation, plugins of the site, so that Jekyll understands how to generate the whole site properly. When I initially migrated from WordPress to Jekyll, I got a lot of HTML files which I need to sometimes customize: I had
head.html that contains
page.excerpt and link to
header.html with site information,
footer.html with Social Network links, and a
default.html meant for a default page with them all(I also had to later add an
analytics.html with Google Analytics code). Then
_syntax-highlighting.scss and many others which I generated once then never touched.
With the new theme, I moved most of the configrations into
_config.yml, and some of them to a
_data folder with a few other YAML files. I no longer need those HTML and CSS files so I deleted them. As a result, I added 355 lines of code, deleted 1277 lines of code, the blog still deploys to GitHub Pages but with more modern look and supported more features (like tagging) that I didn’t get time to bring to my Minima-based site.
One caveat was, Minimum Mistakes is not using the default “post” layout, but using
layout: simple instead. I don’t know the reason behind the choice, but guess what layout will most Jekyll users will keep using when they see their first Jekyll post starts with following metadata?
--- layout: post title: "Welcome to Jekyll!" date: 2020-09-01 11:00:00 +0300 categories: jekyll update ---
So with years of blogging I ended up with hundreds of posts with
layout: post. I felt nervous to simply do a find/replace: what if I need to switch theme again? My solution was just deleting all layout information in my posts and let the theme to figure out, so I ran one script in Terminal:
grep -rl 'layout: post' _posts | xargs sed -i '' -e "/layout: post/d"
When I finished, I eliminated a lot of unnecessary code (added 355 lines, deleted 1277 lines), meanwhile the blog is still deployable to GitHub Pages. The addition was mostly in
_config.yml, the deletion was mostly html and css files.
I did encounter some caveats but they were relatively easier to fix, and by fixing them
Migration from WordPress to Jekyll(2018 or earlier)
At that time I briefly wrote about it in Chinese without technical details. I believe there must be migration tools currently available and easy to use. There is one tip to share though: I wanted to unpublish many posts in the past because either content is rendering weirdly(can be content format itself, can be metadata, thanks to migration after migration), or the post itself is irrelevant(yes the blog is aging like myself). So I wrote some quick Python code basically to add
published: false so that Jekyll skips them:
def unpublish(filepath, pattern): file_handle = open(filepath, "r") contents = file_handle.readlines() file_handle.close() index = 0 for i in range(len(contents)): if pattern in contents[i]: index = i contents.insert(index+1,"published: false\n") f_write = open(filepath, "w") contents = "".join(contents) f_write.write(contents) f_write.close()
Migration from MSN Spaces to WordPress (2011)
I was forced to migrate because MSN Spaces was shutting down, all blogs based on that were told to migrate to Wordpress. That was the first time I realized my content on big platform wouldn’t be guaranteed to “persist”. Microsoft provided a migration solution but it was buggy and troublesome. I wrote in Chinese about it then. I am glad that I chose to not give up blogging and bought my own domain to host it, and this enabled myself to treat this blog as a code repository.
Migration from college BBS to MSN Spaces(2006)
This was the easiest: I just copy-pasted a few posts and ignored all the others. The BBS is now only visible in CERNET which I have no access. I know my account still exists but I am not sure if that blog is still available.