How to blog using GitHub and Eclipse

How to blog using GitHub and Eclipse

If this is not the first post by me that you’re reading, you may know that I try to blog regularly. Previously, I had 2 or 3 private blogs which, you also might know, were not that successful ;). Since I started at EclipseSource, I publish on our company blog.

Anyway, I started my first blog 5 years ago and used some horrible, long forgotten php software. For my other blogs and the EclipseSource blog, WordPress is used. WordPress is probably the winner when it comes to blogging software. It’s widely accepted and heavily used by thousands of bloggers. While I like WordPress a lot, it has some drawbacks. Currently I’m sitting in the train writing this post and what tool do I use? A simple Text Editor. When I arrive at my company I have to paste this post into our WordPress, do a little formatting and publish it. What I really miss in this workflow with the text editior is the history of the post.

As a developer I like trying out the new stuff. As a result I’ve been using Git for a while now and I’m quite happy with it. I’m also an Eclipse committer and the Eclipse IDE is my home. Thanks to my colleagues I’m quite quick with all the shortcuts in the IDE. So, using the IDE as my blog editor and Git as the version control system (aka. history) would feel quite natural to me. But, how can we do this?

Luckily there is GitHub, probably your choice also for a Git hosting service too. Anyone can create a public Git repository for free. In the same way as WordPress is the winner for blog systems, GitHub is the winner when it comes to Git hosting services. What is less well known is that GitHub provides another service called GitHub pages. With pages you can use a Git repository to publish web contents. All you need to do is create a Git repository with a special naming (your-username.github.com) and everything pushed to this repository will be published under https://your-username.github.com (also good for publishing p2 repositories).

What the GitHub folks have also implemented is a Jekyll integration. Jekyll is a blog system that transforms your articles using static templates. You can add a blog post by adding a text file. After writing your posts, all you have to do is push the files to your GitHub pages repository and GitHub automatically starts the Jekyll transformation to create the blog. Isn’t this awesome? You get a blog system with Git as a history and a web hoster for free – in one provider ;).

How does Eclipse come into the game? After cloning your repository to a local destination you can use linked workspace resources to edit the blog post in your IDE. All you have to do is create a new project and change the location to your Git repository root (see screenshot below).

After editing your posts you have the option to use EGit (the Eclipse Git Integration) to push your changes to GitHub (don’t forget to share the project). The only piece missing is an Eclipse Jekyll integration (GSoC Students where are you?). With this I mean, when I save or commit a local blog post, it would be nice if a Jekyll transformation could be triggered to provide a local preview of the blog. Currently I do this by executing a command on the shell.

I’ve decided already that when I have to create a new blog I will use this technique. If you are not convinced yet, check out these example blogs which use GitHub and Jekyll.