用Octopress在github发文章

2014-08-28  本文已影响146人  欧悦服务

参考别人的文章,做了自己的记录。

1.准备工作

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

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

  2. ruby的开发环境,我这使用的Octopress需要Ruby1.9.2,这些我都有了

2.安装Octopress

git clone git://github.com/imathis/octopress.git octopress
cd octopress
gem install bundler  # 安装ruby1.9.2下的bundler
bundle install       # 安装依赖的组件
rake install         # 安装默认的Octopress主题

3.配置github

在github上创建一个仓库,注意仓库名称要以下这种格式yourname.github.io,这样代码发布后自动这个url就可以访问了。

设定 GitHub Pages

rake setup_github_pages

中间会有要求输入用户名地址之类的,照做就好了。

rake generate
rake deploy

如果发布失败,提示版本不同步,可以执行以下操作:

octopress$ cd _deploy

_deploy$ git pull https://github.com/weipipi/weipipi.github.io

_deploy$ git push origin master

octopress$ rake deploy

4.将 source 也加入 git

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

5.更新 Octopress

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

git remote add octopress git://github.com/imathis/octopress.git
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                 #若发布后无效果可试试此命令

8.配置

按已有的项目改想改的内容就可以了。

修改后需要rake generate和rake deploy

为Octopress修改主题和自定义样式

修改网站背景或者配色后,需要rake generate才能生效

上一篇 下一篇

猜你喜欢

热点阅读