octopress搭建记录

  一直想弄个big高点的独立博客,久仰jekyll之威名,今天终于尝试一下,但看到大多的jekyll都。。。所以尝试一下octopress。

  因为有github的帐号,申请的步骤就省掉了。

一  安装ruby:

  octopress是基于ruby的,所以还要在本机上安装ruby。可以借鉴这位仁兄的文章来在Ubuntu下安装ruby。

# 先安装curl工具
sudo apt-get install curl

# 用curl来安装rvm
curl -L get.rvm.io | bash -s stable

  如果安装成功,~/.bashrc:文件中会有:

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

  接下来source:

source ~/.rvm/scripts/rvm

  用rvm安装ruby:

rvm install 1.9.3

  以上有可能出现安装错误的情况:

1 There has been error while updating 'apt-get', please give it some time and try again later.
2 For 404 errors check your sources configured in:
3 /etc/apt/sources.list
4 /etc/apt/sources.list.d/*.list

  可以尝试:

1 rvm autolibs disable
2 rvm install 1.9.3

 

二  安装octopress

  可以执行以下命令:

git clone git://github.com/imathis/octopress.git octopress
cd octopress
gem install bundler
bundle install
rake install

  我在执行到bundle时会报错:

An error occurred while installing RedCloth (4.2.9), and Bundler cannot
continue.
Make sure that `gem install RedCloth -v '4.2.9'` succeeds before bundling.

  不知道这个RedCloth是怎么回事,多种尝试无果,有仁兄说用sudo apt-get install ruby-dev 之后就好了,果然。。。

三  部署

  在自己的github中先新建一个repository,命名为"yourname.github.io"或者"youname.github.com",前面的name必须同你的帐号相同。之后用:

git clone git@yourname.github.io

可以加到本地仓库中。

rake setup_github_pages

会要求你输入URL,将新建的repository粘帖进去就好了。

  接下来就是配置了,在octopress目录下有_config.yml文件,其中的title,subtitle等自己修改就好,这位仁兄说最好把twitter相关的都删了,GFW会使加载速度变慢,google的字体也会被干扰。  

rake new_post ['title']

  就可以新建文章了

rake generate

  能够生成静态文件。

但是此时报错了:

 Could not find a JavaScript runtime.

  安装下nodejs或者execjs可以解决。

  因为我的副标题是是cp936的中文,又报错了:

invalid leading UTF-8 octet

  在/etc/vim/vimrc中修改fileencodings(fenc)=utf-8就好了。

  安装默认主题:

rake install

  可以本机查看:

rake preview

  通过localhost:4000访问:

  然后rake deploy就可以部署了,但是遇到了很棘手的问题:

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

查了很多终于解决,要在_deploy文件夹下运行git push origin master 才能提交,octopress文件夹是个source branch,_deploy文件夹是个master branch。第一次遇到这个问题的时候可以这么解决,在之后提交的时候,编辑完成后`rake deploy`就已经把master branch提交到github了,此时博客已经能看到新post,在octopress文件夹下`git push origin source`,就可以同步source branch到github。

posted @ 2014-08-26 00:03  hyace  阅读(676)  评论(0编辑  收藏  举报