Migrating WordPress to Jekyll
I have a blog which is WordPress based, and it need hosting service and also domain name, as I have a big dream ahead and can’t waste my money on monthly and annually billing, I need to store my thoughts on the internet and share everything. But, why Jekyll? Why not Medium?
I thought medium too, but posting migration to medium is not geeky enough, it’s easy to do, you don’t need to config anything, type `gem install anything` or even touch your `terminal` app. Also, you can find it here https://help.medium.com/hc/en-us/articles/218445047-Migrate-your-WordPress-blog-to-Medium. And the other reason is, I have a freedom to modify my layout, design, anything in Jekyll, compared to Medium.
So, the first thing is, you must have a WordPress based site, github account to store your Jekyll platform, a cup of coffee, and a movie to watch, because waiting installation progress with slow internet connection is a bit boring.
Export WordPress data to XML File.
Open your wp-admin or your dashboard then login, you may `Tools` menu and `Export` on it, just access the `Tools — Export`page.

Then you choose `All content` to export your whole content, including posts and media. Click `Download Export File` button to proceed.
Once you have the file, save it for your backup or anything.
Create a github repository to store your Jekyll blog
I assume you already have a github account, and you have basic knowledge to use it. So, the rule of creating a personal page on github is, you have to create a repository with `username.github.io` format, as my github username is `sendz`, so my repository is `sendz.github.io`.
Then you clone the newly created repository to your local computer using git. For example:
$ git clone https://github.com/githubusername/githubusername.github.io.git

Install Jekyll on Local Machine
Assuming again you are a developer, you already have rubygem on your machine, and ready to call `gem install` command. Install jekyll with `gem install jekyll` or add `sudo` in front of the command if it refuse to install because writing permission issue, or let me give you step by step command
$ gem install jekyll
$ cd githubusername.github.io
$ jekyll new . --force
We use method above because we already cloned repository from github, else, we will use this method
$ gem install jekyll
$ jekyll new awesomename
To start jekyll on your local machine, start command
$ jekyll serve
And open your localhost with port 4000 (http://127.0.0.1:4000/)
Import Your WordPress Content to Jekyll Working Directory
Remember XML file you downloaded? Bring here to your jekyll directory, rename it to wordpress.xml for easy use.
Before we start, you need to install jekyll-import, you can find the documentation here https://import.jekyllrb.com/docs/installation/
$ gem install jekyll-import
Because using WordPress method is a little bit tricky, you need to configure your db and anything and we have no idea what the db configuration is (it’s because I generated my WP installation using installer), the more convenient way is to use WordPress.com import method instead.
Type these 6 lines command on your terminal then enter
$ ruby -rubygems -e 'require "jekyll-import";
JekyllImport::Importers::WordpressDotCom.run({
"source" => "wordpress.xml",
"no_fetch_images" => false,
"assets_folder" => "assets"
})'
- `”source” => “wordpress.xml”` means your backup file location and file name.
- `”no_fetch_images” => false”` means you will fetch entire images and download to your local machine.
- `”assets_folder” => “assets”` means the directory name for all downloaded assets.
Once the progress is completed, you can reload your browser and find all the contents already imported. You may find imported meta shown on post page, I think it’s a bug from jekyll-import which doesn’t translate WP meta to Jekyll meta.
Push to Your Github Repository
If you clone the github repository from the first step, you just need to push to your repository, as simple as
$ git add .
$ git commit -m "Your commit message here"
$ git commit origin master
And github will build your Jekyll page