Running a Jekyll Blog Using Github Pages on Mac OS X 10.8 Mountain Lion

Running a Jekyll Blog Using Github Pages on Mac OS X 10.8 Mountain Lion

Christopher Kaukis
//

In my last post I described installing Ruby on Mac OS X with RVM. The main reason I wanted to do this was to run a Jekyll Blog using GitHub Pages. So, in this post I will guide you through the process to get a GitHub Pages Blog up and going.

1. Installing Python and Pygments with Homebrew

Since we already have Homebrew installed, we can install the Pygments Python Egg rather easily and get some beautiful syntax highlighting for your code posts.

In your terminal execute the following to install Python using Homebrew:

brew install python

After it’s completed, add the following line to your .profile file located at ~/.profile (or /Users/you-user-name/.profile):

export PATH="/usr/local/share/python:${PATH}"

Save it and run:

source ~/.profile

You can also close your terminal and re-open it instead.

Confirm you are using Homebrew’s Python and not your system Python:

which python

It should output the following (assuming default Homebrew setup):

/usr/local/bin/python

Make sure pip is installed and replace setup tools with distribute (an alternative to setuptools):

easy_install pip
pip install --upgrade distribute

Finally, install pygments:

pip install pygments

Onto the next step.

2. Install Jekyll

Assuming you followed the directions in my last post about installing Ruby with RVM and you have it set as your default Ruby you should be able to execute the following command without any errors:

gem install jekyll

3. Setup GitHub Repo

Sign up, login, or go to your GitHub account and create a new repo starting with your username, for example, I created a repo called:

chriskaukis.github.com because my username on GitHub is chriskaukis.

The create new repo link is at the very top right of the page.

4. Clone Your Repo

Clone your repo by executing the following command:

git clone https://github.com/[your-username]/[your-username].github.com

But replace your [your-username] with your username (without the brackets).

This is your GitHub pages blog repository now. Lets set it up with some of the minimal content needed to run.

5. Initial Jekyll Configuration and Setup

At the bare minimum you will want the following files in the root of your repository:

_config.yml (Jekyll uses this for setting custom configuration options.)

.gitignore (Tells git to ignore certain files.)

README (GitHub uses this for your “main” repo page. Do not confuse with your blog page.)

index.html (Your base blog template.)

You will also want the following directories:

_layouts

_posts

_site

To keep this simple and get you up and running fast I’m going to give you an example of each file above with some minimal content.

_config.yml

safe: true
source: .
destination: ./_site
lsi: false
pygments: true

.gitignore

_site/
.DS_Store

README.md (or README. You can change the text. The .md extension means Markdown.)

## GitHub Pages Blog Repository ##
This is the repo for my blog.

index.html

---
layout: default
title: Christopher Kaukis's Blog
---

Posts



    {% for post in site.posts %}
  • {{ post.date | date_to_string }} » {{ post.title }}

  • {% endfor %}

Note: In this file the content between between the — and — are for Jekyll to know the title of the page and the layout to use. The layout is the name of the layout file in _layouts, which we will get to shortly.

Now we need to create a default layout file and a layout for your posts. Finally, we will create your first post and push it to your repo.

In your _layouts directory create a file called layout.html with the following text:




  
   {{ page.title }}


   

My Blog


   

    {{ content }}
   

Dev

Related

Need Expert Help?

See Our Full Menu of Data Services

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072

×

Love our blog? You should see our emails. Sign up for our newsletter!