Who's Studio.

如何配置octopress+github博客

Word count: 465Reading time: 1 min
2016/05/06

写在前面

很久以前就想配置属于自己的博客了,可是一直光说不做,前不久系统升了win10,顺便就想把这个事情也给做了。在配置过程中遇到诸多问题,记录下来方便以后查阅。

搭建环境

我的操作系统是windows10 64bit企业版。

配置流程

1. 安装Git for Windows

直接去git官网下载安装即可。

2. 安装Ruby

RubyInstaller下载Ruby。注意安装时勾选添加到系统环境变量,或者稍后自己手动设置。注意:我在配置时用最新版本Ruby2.3.0到最后一步bundle install时总是失败,无奈改成Ruby2.2.4就成功了。

3. 安装Python2.7

Python官网下载安装。注意安装时勾选添加到系统环境变量,或者稍后自己手动设置。
安装后运行easy_install pygments安装代码高亮脚本。

4. 安装octopress

1
2
3
4
5
6
7
8
$cd <wherever_you_want_to_save_your_blog>
$git clone git://github.com/imathis/octopress.git <your_dir>

$gem install bundle
$bundle install

$rake install
$rake preview

之后在浏览器输入localhost:4000就可以查看了。

5. 部署到Github

在Github上新建一个Repository,命名为username.github.io。然后在cmd中进行部署。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$cd <wherever_your_octopress_is>
$rake setup_github_pages
$https://github.com/your_username/your_username.github.io

$rake deploy

# 新建一篇博文
$rake new_post['title of post']

# 新建一个网页
$rake new_page['name of page']

$rake generate

$rake deploy
访问username.github.io即可查看,可能会有延迟,一般不超过1分钟。

6. 源码维护

在上一步中运行rake deploy后会将生成的静态html页面push到Github,但源码还是在本地。为方便维护,我们可以将源码也push到Github。

1
2
3
$git add .
$git commit -m "source code"
$git push origin source

参考文献

Octopress博客(1)-在windows 10上使用octopress搭建个人博客
Markdown 编辑器语法指南

CATALOG
  1. 1. 写在前面
  2. 2. 搭建环境
  3. 3. 配置流程
    1. 3.1. 1. 安装Git for Windows
    2. 3.2. 2. 安装Ruby
    3. 3.3. 3. 安装Python2.7
    4. 3.4. 4. 安装octopress
    5. 3.5. 5. 部署到Github
    6. 3.6. 6. 源码维护
  4. 4. 参考文献