Using Octopress and GitHub to Build Your BlogCommentsRecent PostsCategories

I have been writing my blogs since today. Here, I am recording and sharing my look at new techniques of Natural Language Processing and Machine Learning, or translating some books and papers writen in English to Chinese. I am using Octopress to support my blogs. It took me a while to install Octopress and published in Github, so I would like to write down my experience and hope that it could be helpful to someone who are facing the same problems.

Octopress is a popular blogging framwork. Unlike WordPress which is supporting dynamic page content, Octopress is a static site and following more hacker way. Under Octopress framwork, you are writing blogs as the pregrammers by using the Markdown language and publishing them under the control of Github.

If you are using WordPress right now and would like to migrate to Octopress, please refer Migrating from WordPress to Octopress.

Installing Octopress

System enviroment: Ubuntu 16.04

Requirements: Git, Ruby 2.0.0 or greater

1
2
3
4
5
6
7
8
9
# Clone repo
$ git clone git://github.com/imathis/octopress.git octopress
cd octopress
# Install dependencies
$ gem install bundler
$ rbenv rehash
$ bundle install
# Install the default Octopress theme
$ rake install

Creating Repo on Github

create a new repository named username.github.io, where username is your username (or organization name) on GitHub.

Setting Up Octopress

1
$ rake setup_github_pages

Input the URL of your Github repo.

1
2
3
# Deploy your website
$ rake generate
$ rake deploy

After this step, you will have your website code in “_deploy”.

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

After this step, you will have your website source code which is used to generate your wbesite code in the branch of “source”.

Installing a new theme

3rd Party Octopress Themes is providing many Octopress Themes with some different characteristics.

1
2
3
4
$ cd octopress
$ git submodule add GIT_URL .themes/THEME_NAME
$ rake install['THEME_NAME']
$ rake generate

Remember to “push” your source code to branch of source after installing a new theme.

Question & Answer

  • the Required Ruby version
    On the office site of Octopress, they are suggesting 1.9.3 or greater versions. This is not correct, and when you are installing your Octopress you will receive an error telling you to install Ruby 2.0.0 or greater.
  • Meet problem from Git when “rake deploy”
    Here is the error message from Git,
1
2
3
4
5
6
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '***************************************'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

This is because some files in your local folder of “deploy” is newer than the online version. You can easily pull_ the online version to replace your local version if you are sure about there are nothing new locally.

1
2
3
4
$ cd octopress/_deploy
$ git pull origin master
$ cd ..
$ rake deploy

Reference

  1. Octopress Setup
  2. Github Pages
  3. Octopress安装和配置
  4. 3rd Party Octopress Themes