Blog on Github
文章目录

- 首先安装
git
|
|
- 安装
rvm和ruby 1.9.3
|
|
- 克隆
octopress到本地
|
|
- 安装依赖
|
|
- 安装
slash主题
|
|
可以定制slash主题,由于众所周知的原因,我把博客的分享换成了国内的jiathis,评论系统换成了国内的多说,需要更改的地方也不是很多,就不详细叙述了,具体可以参考我的代码。当然你也可以使用其他的分享、评论系统,或者使用默认的也行。至于其他的第三方帐号,我只使用了Google Analytics,这个也很简单,就不赘述了。
- 生成网站、预览
|
|
如果你没有改动Rakefile里的server_port的话,默认就可以在 http://localhost:4000/ 查看博客了。
- 部署到github
首先你得有一个github帐号,比如说yourname,然后create repo,名字是yourname.github.com。新手的话可能还需要设置下git和github服务器通信,可以参考github的帮助页,setup-git和generating-ssh-keys等来进行设置。 OK,以上搞定后,可以在本地操作了。
|
|
按照提示输入你的github repo url就可以了。 然后部署。
|
|
等几分种刷新下http://yourname.github.com 应该就不会显示404页面而是你的博客页了。
- 把修改后的
octopress和slash主题也push到github
|
|
这样子的话,这个repo就有了2个branch,一个是master,就是rake generate生成的博客网站,一个是source,就是你修改的octopress配置文件和slash主题。
- 设置域名
|
|
到域名服务商那里设置DNS就可以了。
- 写文章、发表
|
|
这个命令会在source/_posts目录下生成一个markdown文件,编辑这个markdown文件即可。markdown的语法可以在gitcafe上查看。
写了新文章后,push到github。
|
|
然后deploy到github page
|
|
过不了多久就可以在http://yourname.github.com 上查看最新写的文章了。
- 更换工作环境后,恢复octopress和原来的文章
|
|
剩下的安装rvm等参考前面文章。
获得博客网站有两种方式,一是rake generate直接在本地生成,另一种是从github服务器上取回来。
|
|
OK,现在可以继续写博客,然后po了。
后记:
- 写了文章,执行
rake deploy可能会显示错误,修改Rakefile文件里的deploy函数中的push为push -f即可,注意文件中的第18行是修改过的。
desc "deploy public directory to github pages"
multitask :push do
puts "## Deploying branch to Github Pages "
puts "## Pulling any updates from Github Pages "
cd "#{deploy_dir}" do
system "git pull"
end
(Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
Rake::Task[:copydot].invoke(public_dir, deploy_dir)
puts "\n## Copying #{public_dir} to #{deploy_dir}"
cp_r "#{public_dir}/.", deploy_dir
cd "#{deploy_dir}" do
system "git add -A"
puts "\n## Commiting: Site updated at #{Time.now.utc}"
message = "Site updated at #{Time.now.utc}"
system "git commit -m \"#{message}\""
puts "\n## Pushing generated #{deploy_dir} website"
system "git push -f origin #{deploy_branch}"
puts "\n## Github Pages deploy complete"
end
end
- 学习git可以参考看日记学git和pro-git-zh。