Migrate Blog to Octopress

For basic configuration of octopress blog, go to official site for references.

Issue with OS EI Caption (10.11)

After updating OS to EI Caption (10.11), there is some bugs when we run rake preview. You need to update your ruby version, and reinstall dependencies of octopress.

Refer to Errno::ENOENT: No Such File or Directory - Jekyll ~ Octopress and El Capitan post for more details.

If you can still not update your ruby version using the way in the above post, try the following commands (Refer to Using Rbenv to Manage Multiple Versions of Ruby for more details.) before install new ruby version:

  • Add rbenv init to your shell to enable shims and autocompletion:
1
2
$ echo 'eval "$(rbenv init -)"' >> $HOME/.bash_profile
$ source ~/.bash_profile
  • Restart shell as a login shell so that the PATH changes take effect:
1
$ exec $SHELL -l

Themes

Go to here to choose the theme you like. Personally, I like the boldandblue theme. It is simple and elegant.

Code Styles

目前有以下几种插入代码片段的方法:

1
this is code
1
this is code
1
this is code
this is code
this is code

Category list

Go to here, and the guy tells you how to enhance your blog to display the categories.

code syntax highlight

Refer to my previous post on write post for project pages (gh-pages) How to Write Post in Github Pages

Write post

  • go to source branch.
  • in hongchaozhang.github.io folder, run rake new_post["title"], and you will find a well named file with md as the extension. Open it and edit.

Note:The url of post is generated from the post file name in _post folder, and you shouuld only use English charactors there. But inside your site, the title comes from the title property in the yaml header of your post, and other languages are supported here.

use published: false in the yaml header to disable your post from being displayed in the blog.

  • run rake setup_github_pages if you haven’t run it.

This command help you do the followings:

  • Ask for and store your Github Pages repository url.
  • Rename the remote pointing to imathis/octopress from ‘origin’ to ‘octopress’
  • Add your Github Pages repository as the default origin remote.
  • Switch the active branch from master to source.
  • Configure your blog’s url according to your repository.
  • Setup a master branch in the _deploy directory for deployment.
  • run rake generate to generate your new post.
  • run rake preview to start local server at localhost:4000 for testing.
  • If everything is OK, run rake deploy to push the generated site in _deploy to master branch in github (Do it in source branch). In a second, you will see the changes at username.github.io.

If you meet with the following error while pushing your site to master branch:

To git@github.com:hongchaozhang/hongchaozhang.github.io.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:hongchaozhang/hongchaozhang.github.io.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Go to _deploy folder, and run the following commands (reference):

git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git pull

For some times, I just run the following:

git pull origin master
  • push your source code to source branch.

Note: Never push your source code to master branch. master branch should only hold your site.