Creating a GitHub Pages Blog With Octopress on OS X

Summary

  • Install Octopress
  • Setup Github Pages
  • Add remote repository
  • Review Git branches
  • Preview on development
  • Deploy to Github

Prerequisites

  • Install Ruby, Git
  • Have a github account
  • Basic knowledge of Git and github
  • Confidence about the command line

Install Git

Please reference GitHub Help http://help.github.com/mac-set-up-git/ this is relatively simple.

Install Ruby

  • Install RVM(Ruby Version Manager)

Install RVM (development version):

$ curl -sSL https://get.rvm.io | bash

Install RVM stable with ruby:

$ curl -sSL https://get.rvm.io | bash -s stable --ruby

Then you need to configure RVM shortcut commands, or you can not use rvm commands directly in the terminal

$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" ' >> ~/.bash_profile

Meaning is directly inserted into the script .bash_profile in, run

$ source ~/.bash_profile

or restart Terminal, then you can enter the following command to verify

$ type rvm | head -1
rvm is a function

That would prove rvm command to configure a success. You can also run

$ echo $PATH

also to verify.

If you are using Sublime Text as the editor related operations, it also needs to be configured first in the $PATH path subl as shortcut commands, as follows

$ sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/bin/subl

In this case, the above-described rvm configuration can of this operation command

$ subl ~/.bash_profile

You can then add the following text in the edit

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
  • Install Ruby
$ rvm install 2.1.0
$ rvm use 2.1.0

or

$ rvm --default 2.1.0

Verify the settings

$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]

Now confirm Ruby Gems, Gems is Ruby's package manager

$ gem -v
2.2.1

If it is not the latest version, you can

$ gem update --system

Install Octopress

  • Install Octopress
$ git clone git://github.com/imathis/octopress.git octopress
$ cd octopress
$ ruby --version
  • Install Plug-ins
$ gem install bundler
$ bundle install

Tips: keep Jekyll Latest

Because Jekyll updated more frequently, in order to ensure consistency you see in the local debugging with GitHub Pages site effects on, be sure to frequently update Jekyll, recommended bundle update command is as follows

$ bundle update
  • Install Octopress Theme
$ rake install
  • Modify the Configuration

Modify the configuration file _config.yml, modify url, title, subtitle, author, etc., plus the comments disqus, google+, twitter, Facebook, etc., all are together. Create a CNAME file in the source.

  • Create a Repository on GitHub

We’re going to use Github pages. Octopress has some rake tasks to make this easier for you. Your blog will be hosted at http://username.github.io and you need to create a new Github repository called username.github.io that github pages will use the master branch as the html source for your blog.

  • Local configuration GitHub Branch
$ rake setup_github_pages

When the command prompts you to enter Github URL, enter the address you just created git.

  • Writing Articles
$ rake new_post["new article"]

Generate a *.markdown file in "octopress/source _post", now you can edit the article.

  • Generate & Preview
$ rake generate
$ rake preview

This will generate the contents of your blog and allow you to preview it at [http://localhost:4000]

  • Git Submit
$ rake deploy

Finish

Now, you have your site running on Github with Octopress.

Solve FAQ

Slove rake deploy rejected in Octopress

$ rake gen_deploy

I got error

! [rejected]        master -> master (non-fast-forward)

Run the command

$ cd octopress/_deploy
$ git pull origin master
$ cd ..
$ rake deploy

That's it.

Reference Creating a GitHub Pages Blog With Octopress on Ubuntu

Creating a GitHub Pages Blog With Octopress on OS X
1 vote, 5.00 avg. rating (97% score)