DEV Community

Cover image for Importing WordPress or Blogger Blogs to Jekyll Blog
Rupesh Tiwari
Rupesh Tiwari

Posted on • Originally published at rupeshtiwari.com on

Importing WordPress or Blogger Blogs to Jekyll Blog

I have WordPress or Blogger blog and I decided to move away from WordPress and switch to Jekyll. I loved the way Jekyll is working. You can deploy Jekyll blog to GitHub pages for free. Only thing you need is domain. If you want otherwise custom domain is optional. In this article, I will show you how you can export WordPress blogs to your new Jekyll Project. Same technique can be used for Blogger Blogs import and migration to Jekyll project.

Step 1: Downloading WordPress content

Download the WordPress blog Content as xml.

  1. Navigate to https://YOUR-USER-NAME.wordpress.com/wp-admin/export.php Then download you all content in your local box.

For downloading Blogger Blog Content follow the instruction below:

Step 2: Creating Jekyll Project

You need a Jekyll Site and I will use Minimal Mistake Jekyll Theme for my demo.

Step 3: Copy Blog Content XML in Jekyll Project

Copy the wordpress.xml file at root of your Jekyll project wordpress.xml

Step 4: Installing new Gem packages to import WordPress blogs to your Jekyll.

Run gem install hpricot Run gem install open_uri_redirections Run gem install jekyll-import

Step 5: Converting WordPress.org Blogs to Jekyll Blogs

Then run below script at the root location of your Jekyll project to import posts from wordpress.xml

Run below Ruby script:

ruby -r rubygems -e 'require "jekyll-import";JekyllImport::Importers::WordpressDotCom.run({"source" => "wordpress.xml","no_fetch_images" => false, "assets_folder" => "assets" })'

It will create the folders and files in your Jekyll project form WordPress content xml. There will be couple of errors you can ignore them.

All WordPress post already imported.

You will see some new folders like _attachments, _site_reviews, _restimonialss etc.

I am only interested on blogs so I will not use them. We are done importing WordPress blogs to Jekyll below 2 steps are optional.

Converting Blogger.com Blog to Jekyll Blog

Follow the instructions to migrate your blogger.com blogs to Jekyll.

  1. In your Jekyll project install below packages.

gem install feedjira and gem install httparty

  1. Create migrate.rb file at the root of your Jekyll site.
  2. Copy the script from my Gist to migrate.rb ( in my gist fork I fixed the issues for Feedjira latest version)
  3. Open PoserShell on windows from Jekyll site root location and run ruby migrate.rb http://{user}.blogspot.com/feeds/posts/default. Change the user to your blog user name.

  1. Finally your site is migrated successfully.
  2. Run bundle exec jekyll serve --port=4250 to see your site live at http://127.0.0.1:4250/

Renaming html files to md file. (optional)

Notice the _posts folder will get files as html However, the content will be in markdown format. So I am going to rename it to md file. And the reason is I have my GitHub Action to publish all of my markdown post to dev.to.

Renaming blog to md extension

You can use node.js program to rename all of your files in one go. Learn more

const fs = require('fs');
const files = fs.readdirSync(__dirname);

for (const file of files) {
  if (file.endsWith('.html')) {
    console.log(file);
    fs.renameSync(file, file.replace('.html', '.md'), (err) => {
      console.log(err);
    });
  }
}

Enter fullscreen mode Exit fullscreen mode

When I run the script I could rename all of my 400 imported blogs successfully.

Still blog are working and showing okay!

Deleting not required folders

You can also go ahead and delete other folders if you are not planning to use them. Like In my case I am not going to use my WordPress home page or other pages so I will be deleting them.

Assets I will keep since it is used in my blogs.

However I will delete rest extra folders listed below.

Also I will review my draft folder and delete not required blogs.

Site deployed to GitHub Pages and all blogs are showing

Rupesh Tiwari’s Blogs

Github Actions triggered to auto post blog to dev.to account

I had to delete below front matters to publish dev.to successfully. Learn More here… Dev.to Editor Guideline

password: ''
parent_id: '0'
type: post
status: publish

Enter fullscreen mode Exit fullscreen mode

I had to rename excerpt: to description:

That’s it you are all set now!

References:

If you enjoyed this article then please share to your friends and if you have suggestions or thoughts to share with me then please write in the comment box.

Become full stack developer 💻

I teach at Fullstack Master. If you want to become Software Developer and grow your carrier as new Software Engineer or Lead Developer/Architect. Consider subscribing to our full stack development training programs. You will learn Angular, RxJS, JavaScript, System Architecture and much more with lots of hands on coding. We have All-Access Monthly membership plans and you will get unlimited access to all of our video courses, slides , download source code & Monthly video calls.

  • Please subscribe to All-Access Membership PRO plan to access current and future angular, node.js and related courses.
  • Please subscribe to All-Access Membership ELITE plan to get everything from PRO plan. Additionally, you will get access to monthly live Q&A video call with Rupesh and you can ask doubts/questions and get more help, tips and tricks.

You bright future is waiting for you so visit today FullstackMaster and allow me to help you to board on your dream software company as a new Software Developer, Architect or Lead Engineer role.

💖 Say 👋 to me!

Rupesh Tiwari

Founder of Fullstack Master

Email: fullstackmaster1@gmail.com

Website: www.rupeshtiwari.com | www.fullstackmaster.net

Top comments (0)