像hackers一样写博客(一)

1.准备工作

首先你必须要有以下的几样东西:

(1)git,以及github.com帐号,(我这里将blog放置在github上,没有就赶紧注册吧,^_^)

(2)ruby的开发环境,我这使用的Octopress需要Ruby1.9.2,可以使用rbenv或rvm来简单的安装

我使用的是rbenv,简单介绍下安装:

rbenv install 1.9.2-p290

2.安装Octopress,有了它你就可以像黑客一样写博客了哦!兴奋吧,o(∩∩)o...哈哈

git clone git://github.com/imathis/octopress.git octopress
cd octopress
rbenv version     # 检查ruby的版本是否是1.9.2
gem install bundler  #安装ruby1.9.2下的bundler
rbenv rehash     # If you use rbenv, rehash to be able to run the bundle command
bundle install     # 安装依赖的组件
rake install        # 安装默认的Octopress主题

我使用的是rbenv,如果是rvm,可以查看http://octopress.org/docs/setup/,上面有Octopress更加完整的安装介绍

3.配置github

在github上创建一个仓库,注意仓库名称要以下这种格式yourname.github.com,这样代码发布后自动这个url就可以访问了(此处一定要注意哦,我刚开始没注意,死活没得到想要的效果)。

例如你的 GitHub 帐号是 jack 就将 Repository 命名为 jack.github.com, 完成后会得到一组 GitHub Pages URL http://yourname.github.com/ (注意不能用 https协议,必须用 http协议)。

设定 GitHub Pages

rake setup_github_pages

以上执行后会要求 read/write url for repository :

[email protected]:yourname/yourname.github.com.git

rake generate
rake deploy

等待几分钟后,github上会收到一封信:“[yourname.github.com] Page build successful”,第一次发布后等比较久,之后每次都会直接更新。

当你发布之后,你就可以到 http://yourname.github.com 上看到你的博客了.

当然除了github,也可以使用HeroKu或Rsync,详细介绍:http://octopress.org/docs/deploying/

4.将 source 也加入 git

git add .
git commit -m 'initial source commit'
git push origin source
 

5.更新 Octopress

日后有 Octopress 新版本发布,使用以下指令升级。

git pull octopress master     # Get the latest Octopress
bundle install                      # Keep gems updated
rake update_source            # update the template's source
rake update_style               # update the template's style
 

6.发表新文章

rake new_post["新文章名称"]

会在“source/_posts”目录下自动生成“Timestamp-qing-song-an-zhuang-octopress.markdown”,编辑后即可发布:

rake preview

会在本地启动sinatra服务,用浏览器打开 http://localhost:4000 就可以看到效果了。如果都没有问题就可以发布了。

7.发布

rake gen_deploy
rake deploy                 #若发布后效果可试试此命令
 

猜你喜欢

转载自caok1231.iteye.com/blog/1506553