上一篇博客已经说了为何要搭建这个博客系统,本文再也不啰嗦,单刀直入,说如下主题。 1. Octopress是什么 2. Github Page是什么 3. 部署Octopress到Github Pages的过程 4. 部署中遇到的问题php
自动化建立静态博客工具,包括一些模板和一些批处理工具。 用ruby和sass实现的,做者imathis也是compass的做者,compass是什么不是本文的关注点,请读者自行google了解。html
github静态页面,为项目作宣传主页之类的用处。python
github pages免费空间,免费流量,每次的博客改动和博客模板的改动都由git跟踪。没有理由不选择。git
系统:Windows 7github
Git:下载地址web
Ruby:下载地址 注意: 部署octopress到github以前我已经安装过ruby on rails,因此我没有安装上面的ruby 1.9.3。 我安装是railsinstaller-2.2.1,详情请查看:http://railsinstaller.org/en 因此下面的安装过程出不少问题也许和此有关,因此仍是建议直接安装ruby 1.9.3,不要安装railsinstaller。windows
DevKit:下载地址浏览器
Octopress:git://github.com/imathis/octopress.gitsass
安装Git Windows下安装Git很简单,一路next就能够了。ruby
安装Ruby Ruby的安装也是一路next就能够,不过记得勾选“Add Ruby executables to your PATH”,将Ruby的执行路径加入到环境变量中,若是忘记勾选,也能够手动设置。安装完后能够在命令提示符中输入ruby –version 来确认是否安装成功。
安装DevKit DevKit下载下来的是一个自压缩文件,咱们将其解压到D:/DevKit,有两点须要注意:
解压DevKit后,在命令行输入如下命令来进行安装:
1 2 3 |
cd /d D:\DevKit ruby dk.rb init ruby dk.rb install |
1 2 |
cd /d D:\ruby git clone git://github.com/imathis/octopress.git octopress |
下载完成后会在D:\ruby文件中生成octopress文件夹,下面的操做都是基于这个文件夹。
1 2 3 |
cd octopress gem install bundler bundle install |
1 2 |
cd octopress $ rake install |
1
|
$ rake new_post["My first octopress blog"] |
1
|
$ rake preview |
以上已经把octopress博客系统和第一篇博客生成了,接下来要把生成的博客系统和博客部署到github pages。
https://github.com/ Create a new repo 输入名称 username.github.com,注意username改成你的username,不能省略后面的github.com。 eg. caiqinghua.github.com
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结束的地址。
设置步骤自行google解决 也能够不设置SSH,每次输入githib密码上传,请自行google解决
1 2 |
rake generate rake deploy |
一面的deploy只是把_deploy目录上传到你的repo的master分支,即只是把生成的静态博客站点上传到github pages了。下面还须要把生成这个静态站点工具上传到repo的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分支,记载全部的源文件。
猜想缘由:DevKit问题 把Ruby200中的DevKit删除,把path中c:\Ruby200\devkit 删除 从新执行bundle 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成功了
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/ 这个错误无关痛痒,无需解决。
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,前面已经说起
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语法,如何撰写博客,如何个性化设置博客,且听下文分解。