原文链接:http://caiqinghua.github.io/blog/2013/08/26/deploy-octopress-to-github-pages/

引子

上一篇博客已经说了为什么要搭建这个博客系统,本文不再啰嗦,单刀直入,说以下主题。 1. Octopress是什么 2. Github Page是什么 3. 部署Octopress到Github Pages的过程 4. 部署中遇到的问题

理解本文的基本知识

  1. windows命令行基本使用方法(运行中输入cmd,输入enter)
  2. git(学习资料: Pro Git 简体中文版,请自行google下载)
  3. github(github.com)
  4. ruby(本文只要会安装,会用几条命令即可)

什么是octopress?

自动化创建静态博客工具,包括一些模板和一些批处理工具。 用ruby和sass实现的,作者imathis也是compass的作者,compass是什么不是本文的关注点,请读者自行google了解。

什么是github pages?

github静态页面,为项目做宣传主页之类的用处。

为什么部署到github pages?

github pages免费空间,免费流量,每次的博客改动和博客模板的改动都由git跟踪。没有理由不选择。

step by step 部署Octopress到Github Pages

准备

系统:Windows 7

Git:下载地址

Ruby:下载地址 注意: 部署octopress到github之前我已经安装过ruby on rails,所以我没有安装上面的ruby 1.9.3。 我安装是railsinstaller-2.2.1,详情请查看:http://railsinstaller.org/en 所以下面的安装过程出很多问题也许和此有关,所以还是建议直接安装ruby 1.9.3,不要安装railsinstaller。

DevKit:下载地址

Octopress:git://github.com/imathis/octopress.git

安装软件

安装Git Windows下安装Git很简单,一路next就可以了。

安装Ruby Ruby的安装也是一路next就可以,不过记得勾选“Add Ruby executables to your PATH”,将Ruby的执行路径加入到环境变量中,如果忘记勾选,也可以手动设置。安装完后可以在命令提示符中输入ruby –version 来确认是否安装成功。

安装DevKit DevKit下载下来的是一个自压缩文件,我们将其解压到D:/DevKit,有两点需要注意:

  1. 解压目录中没有有中文和空格;
  2. 必须先安装Ruby,而且Ruby需要是RubyInstallser安装。

解压DevKit后,在命令行输入以下命令来进行安装:

1
2
3
cd /d D:\DevKit
ruby dk.rb init
ruby dk.rb install

用Git下载octopress源代码到本地

1
2
cd /d D:\ruby
git clone git://github.com/imathis/octopress.git octopress

下载完成后会在D:\ruby文件中生成octopress文件夹,下面的操作都是基于这个文件夹。

安装Octopress依赖项

1
2
3
cd octopress
gem install bundler
bundle install

安装octopress默认主题

1
2
cd octopress
$ rake install

创建第一篇博客

1
$ rake new_post["My first octopress blog"]

本地预览生成的博客系统和博客

1
$ rake preview

打开浏览器访问 http://localhost:4000/%EF%BC%8C%E4%BD%A0%E7%9A%84%E7%AC%AC%E4%B8%80%E7%AF%87%E5%8D%9A%E5%AE%A2%E5%B0%86%E5%91%88%E7%8E%B0%E5%9C%A8%E7%9C%BC%E5%89%8D%E3%80%82

以上已经把octopress博客系统和第一篇博客生成了,接下来要把生成的博客系统和博客部署到github pages。

创建git repository

https://github.com/ Create a new repo 输入名称 username.github.com,注意username改为你的username,不能省略后面的github.com。 eg. caiqinghua.github.com

设置刚刚创建的repository路径到本地

1
2
3
4
$ rake setup_github_pages
Enter the read/write url for your repository
(For example, 'git@github.com:your_username/your_username.github.com)
Repository url:

请输入:git@github.com:yourname/yourname.github.com.git (将yourname替换成你的github登录名)

注意:这一步不要输入提示中提示的以io结束的地址。

设置SSH

设置步骤自行google解决 也可以不设置SSH,每次输入githib密码上传,请自行google解决

部署你的博客

1
2
rake generate
rake deploy

一面的deploy只是把_deploy目录上传到你的repo的master分支,即只是把生成的静态博客站点上传到github pages了。下面还需要把生成这个静态站点工具上传到repo的source分支

提交的source目录

1
2
3
4
cd /d D:\ruby\octopress
git add .
git commit -m "My octopress blog source code"
git push origin source

到github.com查看你上面新建的repository,会多一个source分支,记载所有的源文件。

安装过程中遇到的问题

1. bundle install 过程中Installing rdiscount (2.0.7.3) 安装失败

猜测原因:DevKit问题 把Ruby200中的DevKit删除,把path中c:\Ruby200\devkit 删除 重新执行bundle install 成功了

2. rake install 错误

1
2
3
4
d:\ruby\octopress>rake install
rake aborted!
You have already activated rake 10.1.0, but your Gemfile requires rake 0.9.2.2.
Using bundle exec may solve this.

解决办法: 修改octopress/Gemfiles gem ‘rake’, ‘~> 0.9’ 改为 gem ‘rake’ 再次rake install成功了

3. rake setup_github_pages ‘hellip’ 不是内部或外部命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
d:\ruby\octopress>rake setup_github_pages
Enter the read/write url for your repository
(For example, 'git@github.com:your_username/your_username.github.io)
or 'https://github.com/your_username/your_username.github.io')
Repository url: git@github.com:caiqinghua/caiqinghua.github.io
Added remote git@github.com:caiqinghua/caiqinghua.github.io as origin
Set origin as default remote
Master branch renamed to 'source' for committing your blog source files
rm -rf _deploy
mkdir _deploy
cd _deploy
Initialized empty Git repository in d:/ruby/octopress/_deploy/.git/
'My Octopress Page is coming soon
'hellip' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
[master (root-commit) 7e72dcf] Octopress init
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 index.html
cd -
---
## Now you can deploy to git@github.com:caiqinghua/caiqinghua.github.io with `ra
ke deploy` ##

google: ‘hellip’ 不是内部或外部命令,也不是可运行的程序 http://pythonee.github.io/blog/2012/08/10/how-to-octpress/ 这个错误无关痛痒,无需解决。

4. rake deploy

1
2
3
4
5
6
## Pushing generated _deploy website
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

解决办法:设置ssh,前面已经提及

5. 再次rake deploy,发生以下错误

1
2
3
4
## Pushing generated _deploy website
Enter passphrase for key '/c/Users/Lin/.ssh/id_rsa':
ERROR: Repository not found.
fatal: Could not read from remote repository.

问题原因:rake setup_github_pages 中 git@github.com:caiqinghua/caiqinghua.github.io设置错误,应该设置为 git@github.com:caiqinghua/caiqinghua.github.com.git 解决办法: 查看octopress_deploy.git\config

发现url错误,修改后,重试,部署完成

1
2
[remote "origin"]
url = git@github.com:caiqinghua/caiqinghua.github.io

修改为

1
2
[remote "origin"]
url = git@github.com:caiqinghua/caiqinghua.github.com.git

注意: octopress.git\config 中的url也生成错了。

1
2
[remote "origin"]
url = git@github.com:caiqinghua/caiqinghua.github.io

应该修改为

1
2
3
[remote "origin"]
url = git@github.com:caiqinghua/caiqinghua.github.com.git
fetch = +refs/heads/*:refs/remotes/origin/*

重新执行rake gen_deploy执行成功了

立即访问 caiqinghua.github.com,提示404 页面未找到错误 10分钟后访问,可以看到本地预览的博客了。 到此部署octopress到github pages总算完成了。

后记

octopress中用markdown格式撰写博文,关于markdown语法,如何撰写博客,如何个性化设置博客,且听下文分解。

Posted by 蔡清华 caiqinghua@126.com Aug 26th, 2013  opensourcetools

在github Pages上部署octopress搭建个人博客系统的更多相关文章

  1. Centos 7使用docker部署LAMP搭建wordpress博客系统

    0.简要概述 LAMP是目前比较流行的web框架,即Linux+Apache+Mysql+PHP的网站架构方案.docker是目前非常流行的虚拟化应用容器,可以为任何应用创建一个轻量级.可移植的容器. ...

  2. github pages + Hexo + 域名绑定搭建个人博客增强版

    概述 前面我们用github pages + Hexo 搭建了一个简单版的个人博客系统,但是里面的内容单调,很多功能不够完善,所以我们需要对yelle 的主题进行优化和完善.基本搭建请访问:http: ...

  3. github pages + Hexo + 域名绑定搭建个人博客

    环境 Windows 10(64 位) Git-2.7.4-64-bit node-v4.4.7-x64 如果上述软件已经安装的,跳过,没有安装的下载安装. 1,git下载安装(https://git ...

  4. 博客Hexo + github pages + 阿里云绑定域名搭建个人博客

    申请域名 万网购买的域名,地址:https://wanwang.aliyun.com/domain/com?spm=5176.8142029.388261.137.LoKzy7 控制台进行解析 控制台 ...

  5. Hexo + github pages + 阿里云绑定域名搭建个人博客

    申请域名 万网购买的域名,地址:https://wanwang.aliyun.com/domain/com?spm=5176.8142029.388261.137.LoKzy7 控制台进行解析 控制台 ...

  6. 使用github + Octopress 搭建免费博客 + 碰到问题的解决方法

    使用github + Octopress 搭建免费博客,先说碰到的问题,具体创建方法见下面. 问题1, 添加ruby淘宝链接问题,显示无法获取, 解决: source “http://ruby.tao ...

  7. windows上使用mkdocs搭建静态博客

    windows上使用mkdocs搭建静态博客 之前尝试过用HEXO搭建静态博客,最近发现有个叫mkdocs的开源项目也是搭建静态博客的好选择,而且它支持markdown格式,下面简要介绍一下mkdoc ...

  8. day09搭建均衡负载和搭建BBS博客系统

    day09搭建均衡负载和搭建BBS博客系统 搭建BBS博客系统 本次搭建bbs用到的技术 需要用到的: 1.Nginx+Django 2.Django+MySQL 环境准备 主机 IP 身份 db01 ...

  9. 一步步在 github pages 上用 jekyll 搭建属于自己的博客

    序 我的专业与互联网没有太大关系,接触博客还是工作以后的事情.随着工作的经验增加,总想将自己的所思所得记录下来,毕竟,好记性不如烂笔头. 开始是将自己的总结在本地保存,但是本地有一个劣势,就是不能随时 ...

随机推荐

  1. Redis学习篇(十二)之管道技术

    通过管道技术降低往返时延 当后一条命令不依赖于前一条命令的返回结果时,可以使用管道技术将多条命令一起 发送给redis服务器,服务器执行结束之后,一起返回结果,降低了通信频度.

  2. 高并发编程之ReentrantLock

    上文学习jvm提供的同步方法synchronized的用法,一些常见的业务类型以及一道以前阿里的面试题,从中学习到了一些并发编程的一些规则以及建议,本文主要学习jdk提供的同步方法reentrantL ...

  3. NOI2005 维护数列(splay)

    学了半天平衡树,选择了一道题来写一写,发现题目是裸的splay模板,但是还是写不好,这个的精髓之处在于在数列的某一个位置加入一个数列,类似于treap里面的merge,然后还学到了题解里面的的回收空间 ...

  4. 「UOJ207」共价大爷游长沙

    「UOJ207」共价大爷游长沙 解题思路 : 快速判断两个集合是否完全相等可以随机点权 \(\text{xor}\) 的思路可以用到这道题上面,给每一条路径随机一个点权,维护出经过每一条边的点权的 \ ...

  5. 【tarjan+拓扑】BZOJ3887-[Usaco2015 Jan]Grass Cownoisseur

    [题目大意] 给一个有向图,然后选一条路径起点终点都为1的路径出来,有一次机会可以沿某条边逆方向走,问最多有多少个点可以被经过?(一个点在路径中无论出现多少正整数次对答案的贡献均为1) [思路] 首先 ...

  6. [AtCoder-ARC073F]Many Moves

    题目大意: 有一排n个格子和2枚硬币. 现在有q次任务,每一次要你把其中一枚硬币移到x的位置上,移动1格的代价是1. 两枚硬币不能同时移动,任务必须按次序完成. 现在告诉你两枚硬币初始状态所在的位置a ...

  7. 【BZOJ】2724: [Violet 6]蒲公英

    2724: [Violet 6]蒲公英 Time Limit: 40 Sec  Memory Limit: 512 MBSubmit: 2900  Solved: 1031[Submit][Statu ...

  8. bzoj4567 背单词

    Description Lweb 面对如山的英语单词,陷入了深深的沉思,“我怎么样才能快点学完,然后去玩三国杀呢?”.这时候睿智 的凤老师从远处飘来,他送给了 Lweb 一本计划册和一大缸泡椒,他的计 ...

  9. PAT甲级1066. Root of AVL Tree

    PAT甲级1066. Root of AVL Tree 题意: 构造AVL树,返回root点val. 思路: 了解AVL树的基本性质. AVL树 ac代码: C++ // pat1066.cpp : ...

  10. (转)Ext.Button点击事件的三种写法

    转自:http://maidini.blog.163.com/blog/static/377627042008111061844345/ ExtJs的写法太灵活了,现在收集了关于Button点击事件的 ...