Read time: 3 minutes
Hi,
I recently shifted my blog from https://mandeep7.wordpress.com to https://blog.mandeeps.me which uses Jekyll and is being hosted on GitLab Pages as of today. The main purpose of shifting it to Jekyll is the ease of publishing content. Just write the content in your text editor of your choice e.g. mine is Vim and publishing it will just a few keystrokes away. Obviously, you get complete control over your website/blog as a reward.
I will write another post about setting up Jekyll. You may see basic stuff at jekyllrb.com though. Now coming to the main thing about how I shifted it from wordpress.com to Jekyll with all my posts intact.
- First of all you will need to log in to your wordpress account (probably one last time) and Export all of your data. Go to your dashboard and in the left pane My Site -> Settings -> Export. Export all of your content and a single xml file will be downloaded.
- Next to port this to Jekyll, you will need to convert the posts from this xml file to Jekyll-readable format. Jekyll needs markdown format (with a little bit YAML) for the posts. I used a converter I found on GitHub: https://github.com/joepie91/wpcom-to-jekyll I know it’s not been updated since a while but it did the job for me. I had to make some changes to this script to convert tags and categories properly into the Jekyll posts.
- After feeding your exported XML file to this converter, you will get some
folders in the current directory. It will include
_posts
folder which contains all of your posts in Markdown format. It will also includeattachments
that contains all the media you posted in the blogs,_layouts
,_drafts
,about
etc. You most probably will need to copy this_posts
andattachments
folders to the Jekyll project directory. - Now running
bundle exec jekyll serve
should do the job. You may look up your blog up and running at http://127.0.0.1:4000. - That’s it!
You may face some issues while trying to run the serve command. Sometimes you
won’t even find where the error actually is. To find out, I tried to copy around
20 posts at once into the _posts
folder to see which post is the root cause.
I had a few issues like:
- Wordpress-converted Jekyll posts will still have [code][/code] tags for the syntax highlighting for the code.
- Tags and categories having numbers will give error. So need to remove them.
-
Images may have http links. Also, images have some relative links like ../../../image.png. But you will need links like:
![image.png]({{site.url}}/attachments/image.png)
if the file is stored in attachments.
- If your wordpress post’s title contained double-quote characters (“), then it
will surely raise an error. You may replace it with single-quote (‘). It’s
because
title
variable already uses double-quotes. - If your post content contains something like {{abc}} ,
then you will need to wrap it within
{% raw %}
and{% endraw
%}
tags. It’s because it conflicts Jekyll’s templating engine i.e. Liquid’s syntax.
That’s it for my first post using Jekyll.