Yiiwood's Blog

自强不息,厚德载物

Octopress Blog 配置

| Comments

一、本地环境配置

1、安装Git
2、安装Ruby,加入环境变量。
3、安装Devkit,首先解压,然后用如下CMD命令安装:

1
2
3
cd DevKit
ruby dk.rb init
ruby dk.rb install

4、安装python
5、下载Octopress,执行下面的git命令:

1
git clone git://github.com/imathis/octopress.git  octopress

6、加入中文UTF-8编码支持,Windows环境变量配置如下:

1
2
LANG=zh_CN.UTF-8
LC_ALL=zh_CN.UTF-8

7、更新源,执行如下CMD命令:

1
2
gem sources -a http://ruby.taobao.org/
gem sources -r http://rubygems.org/

8、安装Octopress,执行CMD命令:

1
2
3
cd octopress
gem install bundler
bundle install

二、建立Github项目

登录Github,新建一个命名为 username.github.com 的Repo。

三、发布Octopress到Github

1、执行CMD命令,按照提示输入Repo地址(git@github.com:username/username.github.com):

1
2
cd octopress
rake setup_github_pages

2、发布,git命令(#号后面是注释):

1
2
3
4
rake install      #安装主题
rake generate     #生成静态页面
rake preview      #本地预览
rake deploy       #发布到Github

本地预览地址http://localhost:4000/

3、源文件发布到source分支下面,git命令:

1
2
3
git add .
git commit -m “your message”
git push origin source

4、更新博客后,执行rake generaterake deploy

四、一些Markdown语法

1、代码块

(1)在每行代码前面空Tab键:

1
2
3
4
5
6
7
/*每行前空Tab*/
	int main()
	{
		int i;
		i = 0;
		return 0;
	}

效果:

int main()
{
	int i;
	i = 0;
	return 0;
}

(2)用codeblock和endcodeblock作为代码块的开头和结尾,效果:

1
2
3
4
int main()
{
	printf("Hello World\n");
}

2、引用块

代码:

1
2
3
4
5
> This is the first level of quoting.
>
> > This is nested blockquote
>
> Back to the first level.

效果:

This is the first level of quoting.

This is nested blockquote

Back to the first level.

五、加入Latex支持

1、首先安装kramdown包:

1
gem install kramdown

再把下面的代码添加到source/_includes/custom/head.html文件中:

修改_config.yml

1
markdown: kramdown  #rdiscount

2、例子

插入代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$$
\begin{align*}
  & \phi(x,y) = \phi \left(\sum_{i=1}^n x_ie_i, \sum_{j=1}^n y_je_j \right)
  = \sum_{i=1}^n \sum_{j=1}^n x_i y_j \phi(e_i, e_j) = \\
  & (x_1, \ldots, x_n) \left( \begin{array}{ccc}
      \phi(e_1, e_1) & \cdots & \phi(e_1, e_n) \\
      \vdots & \ddots & \vdots \\
      \phi(e_n, e_1) & \cdots & \phi(e_n, e_n)
    \end{array} \right)
  \left( \begin{array}{c}
      y_1 \\
      \vdots \\
      y_n
    \end{array} \right)
\end{align*}
$$

效果:

单行代码:$\exp(-\frac{x^2}{2})$,效果:$\exp(-\frac{x^2}{2})$

Comments