Rabi Kavoori

Principal Software Engineer
Works at Oath:
(which acquired Millennial Media)
(which acquired Nexage)
Lives in Atlanta, GA

TwitterGitHubRSS


About

Java developer, currently into Scala, likes to tinker, tries to solve all problems in life by writing code and loves the great indoors!

Using Jekyll for Blogging

[   Blog   ]            

After using Hexo for a while to generate static content for my blog, I discovered Jekyll, which I like a lot more than Hexo. It is much easier to use, has better documentation and it is actually the blogging platform that powers GitHub Pages. This means it should be easy to deploy your site using Github for free! (even with a custom domain!)

Here is another 10 minute installation guide to get it up and running.

Installation

The only requirements are :

1. Install Ruby using Homebrew or the default package manager on your Linux OS.

(If you don’t have Homebrew on your Mac OSX, you should install it!)

brew install ruby
sudo apt-get install ruby

2. Install RubyGems and upgrade to the latest version.

gem update --system   

3. Install Node.js

The best way to install Node.js is installing with nvm.

curl https://raw.githubusercontent.com/creationix/nvm/v0.17.2/install.sh | bash

The above script clones the nvm repository and also adds the source line to ~/.bashrc (or ~/.bash_profile or ~/.profile)

Run the following to get a list of all the Node.js versions available and choose the version to install.

nvm ls-remote

Install the version you have chosen by running the following:

nvm install 0.11.14

Install Jekyll with RubyGems

The best way to install Jekyll is via RubyGems. Run the following on the terminal. This will add jekyll executable to your path.

gem install jekyll

Now you can start using Jekyll. See the documentation if you run into any issues.

Start using Jekyll

Create a new blog and start your blog on your localhost

jekyll new blog
cd blog
jekyll serve [--port PORT] [--watch]

This will start your blog on localhost on port 4000 (or at the PORT if you used the --port flag). Browse to http://localhost:[PORT] to see your new blog.The --watch flag will watch for changes and generate the content automatically without having to restart jekyll.

Create a new post

Create a new post by creating a new file under _posts folder. The file name should follow the following format.

YEAR-MONTH-DAY-title.MARKUP

Here is an example

touch _posts/2014-11-06-my-first-post.MARKUP

Edit the above file and add your content using markdown syntax.

Build your site

The following will generate your site into the _site folder. Now you can FTP the contents of the _site folder your hosting provider.

jekyll build

Here is the best feature of Jekyll.

Host your blog for free at GitHub Pages.

All you have to do is create a repository in your GitHub account with the name [githubusername].github.io and push the entire contents of your blog (not just the blog/_site folder) to the repo. Give it a few minutes and now browse to http://[githubusername].github.io. Your blog should be hosted there for free!

Here are the detailed steps.

  1. Create a new github repo as : [githubusername].github.io
  2. Initialize a new git repo under the Jekyll blog folder by running: git init
  3. Add the remote origin: git remote add origin git@github.com:[githubusername]/[githubusername].github.io.git
  4. Add and commit: git add --all && git commit -m"Initial commit
  5. Push to the origin/master: git push -u origin master
comments powered by Disqus