使用octopress搭建github Pages

安装git,ruby

安装octopress并搭建博客

1
2
3
4
git clone git://github.com/imathis/octopress.git octopress
cd octopress
bundle install
rake install

初始化博客

1
rake setup_github_pages

编辑_config.yml写入博客名和其他信息

开始书写博客:

1
2
rake new_page["About"]    # 添加博客页
rake new_post["First Post!"]  # 新建一篇文章

发布到github

deploy.sh
1
2
3
4
5
6
7
rake generate      # 生成页面
#rake preview       # 如果需要在本地预览生成的结果,预览页http://localhost:4000
rake deploy        #发布到github
# 发布到github的pages在master分支,还要保存源的source分支
git add .
git commit -m 'Added About page and first post!'
git push origin source

在另外机器编辑博客

如果更换了电脑,在新机器上编辑写博客,不需要重新搭建一遍:

get_my_blog.sh
1
2
3
4
5
6
7
8
9
git clone git@github.com:username/username.github.com.git
cd username.github.com
git checkout source
mkdir _deploy
cd _deploy
git init
git remote add origin git@github.com:username/username.github.com.git
git pull origin master
cd ..

Comments