How I migrated my blog from Wordpress to Octopress
Yesterday I decided to try a markdown powered blog platform, Octopress with Github Pages hosting
Reason for this change is probably the same as yours, person who reads this
- Wordpress sucks at formatting code
- Most of my "notes" and "readme" from various projects are markdown files, so if I decided to publish one of them, copy paste wasn't enough
- 3rd, and probably most important. "Hey, we are programmers" we can't use Wordpress ;-)
If you have more reasons, fell free to give a comment below.
This is not a complete guide, I decided to write few keypoints that could help others with migrating their Wordpress to Octopress.
Installing Octopress
How to setup Octopress on Ubuntu
Migrating permalinks
On old Wordpress blog I had this permalink structure
/blog/:id/:title
while it was ok back then, because I could modify title without loosing back links, with Octopress ids aren't used anymore.
I decided to go with standard permalink structure
/blog/:year/:month/:day/:title
Ok, but problem is
Now it's time to get old Wordpress links working in Octopress
Redirect 301 on Github Pages, move old posts to the new permalink structure
We want to keep old links working. Best solution would be 301 redirect all old posts.
Unfortunately this cannot be done the "HTTP way" by sending proper response headers (without JS) on Github pages. But there is a solution for that.
First, include an entire Wordpress blog in read only mode.
Dump an entire Wordpress blog to your disk using wget
How to Recursively Download an Entire Website Using WGET
In my case all downloaded posts were in /blog directory, so to get them still working on Octopress I had to copy
/wp-content
/blog
to
/source/wp-content
/source/blog
If you used other permalink structure for instance
/:title
You need to copy every directory, sorry! :(
Now edit each /:title/index.html
file and put these inside <head>
<meta http-equiv="refresh" content="0; url=http://konradpodgorski.com/blog/2013/10/21/how-i-migrated-my-blog-from-wordpress-to-octopress/">
<link rel="canonical" href="http://konradpodgorski.com/blog/2013/10/21/how-i-migrated-my-blog-from-wordpress-to-octopress/" />
Unfortunately you need to do this manually in most cases.
Using <meta http-equiv="refresh"
will redirect each visitor to the new post.
As for Google Bot, it threats <link rel="canonical" href=
as 301 redirect, well.. not exactly but effect is that you get your pages reindexed and that is what you want.
Now there is no longer need to put any notice about the fact that this is archived post etc.
Migrating comments
I decided to go with Disqus
- Register on Disqus
- On still working Wordpress blog change permalink structure to the same as your new Octopress blog (very important!)
- With changed structure install "Disqus" plugin, log in and export current Comments.
- Because we changed permalink structure all comments will get mapped to the one that will be used in Octopress
edit _config.yml and enter your shortname
# Disqus Comments
disqus_short_name: konradpodgorski
disqus_show_comment_count: true
That's it
for now