Foolishwolf’s Code BlogHow I Posted My First Blog on GithubRecent Posts

This blog is mainly about how to post a blog on Github with Octopress, and the setup of a Markdown-style document editor - Sublime Text is also introduced.

 

1. Octopress

What is Octopress

Octopress is a blogging tool build with Ruby, and can be downloaded from Github.

How to build the Octopress

Here is the building process on Ubuntu, and it seems similar on other OS.

Install Git

1
$sudo apt-get install git

Install Ruby

1
$sudo apt-get install ruby ruby-dev

Download Octopress

Clone the octopress to local directory octopress:

1
$git clone git://github.com/imathis/octopress.git octopress

Install the dependencies

Enter the directory of octopress:

1
$cd ocopress

And type in following command:

1
2
3
$gem install bundler 
$rbenv rehash 
$bundle install 

Install default theme of Octopress

1
$rake install

Initiate blog pages and commit source

Before posting a new blog to Github, a respository with the name yourname.github.io is expected to bulid.
Then run the setup:

1
$rake setup_github_pages

Follow the instructions and type in the answers of what they ask.
Finally, generate and deploy your blog site onto Github:

1
2
$rake generate
$rake deploy

The source for your blog should also be committed:

1
2
3
$git add .
$git commit -m 'your comments'
$git push origin source

Posting a new blog

Use command rake new_post[] to create a new blog file in source/_post:

1
$rake new_post['Title of Your New Blog']

Everytime before posting a new blog, command:

1
2
$rake generate
$rake deploy

should be run to generate the formatted blog and deploy it to Github.

2. Local Markdown editor - Sublime Text

After the Octopress is build, what we need now is a powerful editor helping to write a markdown-style document gracefully. And Sublime Text is just one perfect choice.

Installation

Sublime Text is a cross platform and sophisticated text editor for code, markup and prose. Once being installed and it can be evaluated for free. However, such a powerful editor does not directly enable markdown-style editing. Therefore, it is necessary to add markdown packages into Sublime Text.

Steps:

  • Use Ctrl+` to call the console.
  • Copy following code into the command line of console:
1
import urllib2,os; pf='Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler( ))); open( os.path.join( ipp, pf), 'wb' ).write( urllib2.urlopen( 'http://sublime.wbond.net/' +pf.replace( ' ','%20' )).read()); print( 'Please restart Sublime Text to finish installation')
  • Press key Enter to run the code above and then restart Sublime Text 2.
  • Use Ctrl+Shift+P to call the Command Palette.
  • Type in PCIP and press key Enter.
  • Type in key words to find package Markdown Preview and package Markdown Editing.
  • Click and install these two packages.
  • Done!

    Congratulations! Let us undertake to write blogs on Github!