原文链接: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  opensource, tools

在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. POJ 2378 Tree Cutting 3140 Contestants Division (简单树形dp)

    POJ 2378 Tree Cutting:题意 求删除哪些单点后产生的森林中的每一棵树的大小都小于等于原树大小的一半 #include<cstdio> #include<cstri ...

  2. 【最大独立集】BZOJ3175- [Tjoi2013]攻击装置

    [题目大意] 给定一个01矩阵,其中你可以在0的位置放置攻击装置.每一个攻击装置(x,y)都可以按照“日”字攻击其周围的 8个位置(x-1,y-2),(x-2,y-1),(x+1,y-2),(x+2, ...

  3. 字符约束条件的SQL注入攻击

    引言 目前值得高兴的是,开发者在建立网站时,已经开始关注安全问题了——几乎每个开发者都知道SQL注入漏洞了.在本文中,我将为读者介绍另一种与SQL数据库相关的漏洞,虽然它的危害性与SQL注入不相上下, ...

  4. ElasticSearch学习笔记--2、ES相关配置

    1.配置文件 ES的配置文件位置:config/elasticsearch.yml可以直接搜索elasticsearch.yml 2.配置远程api访问 network.host: 192.168.1 ...

  5. 工作中用到的git命令

    1.git stash 将本地的修改藏匿,不进行commit也可切换分支 2.git stash apply 将之前藏匿的修改恢复出来 3.git cherry-pick commitId git在当 ...

  6. 三、python的数据类型 列表、元组、字典

    1.list 列表 列表是由一序列特定顺序排列的元素组成的.可以把字符串,数字,字典等都可以任何东西加入到列表中,列表中的元素之间没有任何关系.列表也是自带下标的,默认也还是从0开始. List常用的 ...

  7. [转]Android应用中返回键的监听及处理

    用户在点击手机的返回按钮时,默认是推出当前的activty,但是有时用户不小心按到返回,所以需要给用户一个提示,这就需要重写onkeydown事件,实现的效果如下:   标签:    Android ...

  8. md5加密,md5加盐加密和解密

    package com.java.test; import java.security.MessageDigest; import java.security.SecureRandom; import ...

  9. Git配置非22端口,解决:ssh: connect to host xxx port 22: Connection timed out fatal: The remote end hung up unexpectedly

    背景:私自搭建了Git服务器,而Git本身就是SSH进行连接的,而Git命令上默认只能通过22端口实现. 解决方法: 第一种: 在系统的用户目录下的文件夹:.ssh 如果该路径下没有config文件, ...

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

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