在Cygwin下部署github Octopress博客环境

Published on:

本文以Cygwin下快速搭建octopress github博客为目的,没有任何研究学习价值,仅供参考。

首先是配置ruby环境

输入:

1
rvm list

如果显示当前版本是<1.9.3或者找不到rvm命令,则需运行下面命令进行ruby环境安装.不懂ruby,所以以下照搬组合网上的命令:

1
2
3
4
5
curl -L https://get.rvm.io | bash -s stable --ruby
source ~/.profile
rvm install 1.9.3
rvm use 1.9.3
rvm rubygems latest

下载octopress源码

1
2
git clone https://github.com/imathis/octopress.git
cd octopress

配置安装octopress依赖

1
2
gem install bundler
bundle install

如果遇到错误:

1
An error occurred while installing posix-spawn (0.3.6), and Bundler cannot continue。

按下面步骤进行posix-spawn编译安装

1
2
3
4
5
6
7
8
gem install rake-compiler -v 0.7.6
git clone https://github.com/rtomayko/posix-spawn.git
cd posix-spawn
git checkout 2d67c5e6eea5fe50823ca864639b5ae1e25928e3 #恢复到版本0.3.6进行编译
rake gem
gem install pkg/posix-spawn-0.3.6
cd ..
bundle install

如果遇到错误:

1
You have already activated rake 10.1.0, but your Gemfile requires rake 0.9.2.2. Using bundle exec may solve this.

按下面步骤删除rake 10.1.0

1
2
3
4
5
6
gem uninstall rake
Select gem to uninstall:
 1. rake-0.9.2.2
 2. rake-10.1.0
 3. All versions
> 2

创建建username.github.io仓库

在github上创建一个名为username.github.io的源码repo,username为你的github用户名

编辑octopress配置文件_config.yml

twitter相关的都设成false

删除source/_includes/custom/custom/head.html里的google字体

墙内都懂的,引用google字体会造成页面加载缓慢

安装主题(Themes)

一般情况下直接安装默认主题即可,反正以后也是可以修改的

1
rake install #安装默认主题

也可以这里挑选第三方主题: https://github.com/imathis/octopress/wiki/3rd-Party-Octopress-Themes

setup_github_pages

输入以下命令进行github page关联,按要求输入即可

1
rake setup_github_pages

发布文章

1
rake new_post["title"]

创建好了一篇博文,按提示编辑source/_post/xxx.markdown这个文件输入博文内容,语法就是markdown,用过github应该都很熟悉了.

更新文章到github

输入:

1
2
rake generate
rake deploy

创建并上传文章到github,期间可能会需要输入github ssh key密码等内容,按提示输入即可. 还有个rake preview命令可以预览,不过在cygwin下好像没用.就忽略掉吧,反正传上去之后也可以看到效果.