Octopress建立GitHub Pages——基于代码托管的静态博客

Github Pages是静态网页来的,官方也半承认了它的博客用途,代码挂在github上,随时均可以更改,算是不错的一种尝试,由于它是静态的,因此在表现上会自由得多,可是,一样由于它是静态的,管理上也会麻烦得多。在网上溜达时看到一句话——像黑客同样写博客。哈,挺有趣的,用命令行写博客也不成问题了!git

1、新建项目

首先你要有GitHub帐号,再次有GitHub客户端程序,推荐使用msysgitgithub

打开你网页上的github,新建一个repo,命名为xzh-loop.github.comubuntu

2、安装Ruby和DevKit

1. 下载地址:http://rubyinstaller.org/downloads/ruby

2. Ruby:直接安装。markdown

3. DevKit:先解压到一目录,如DevKit,而后:oop

  > cd DevKit
  > ruby dk.rb init

4. 修改DevKit目录下的config.yml文件,在最后添加一行:- E:/Ruby200-x64  #这是你刚刚安装ruby的目录post

5. 再切换回到cmd:this

  > ruby dk.rb install
  > gem install rdiscount --platform=ruby

6. 查看是否安装成功:spa

  > ruby --version
  > git --version

3、octopress

1. F盘下新建octopress文件夹,把octopress项目的代码克隆到本地了。命令行

  > f:
  > git clone git://github.com/imathis/octopress.git octopress

2. 由于源比较慢,先修改文件夹下的Gemfile文件(第一行换成淘宝的镜像):source "http://ruby.taobao.org"

  > cd octopress
  > gem install bundler
  > bundle install(一行行地安装,貌似挺多的)
  > rake install(安装默认主题)
  > rake preview(等一下子,就能够输入localhost:4000访问本地博客了,Ctrl+C退出)

4、部署到Github

  > cd octopress
  > rake setup_github_pages
    输入远程仓库地址https://github.com/xzh-loop/xzh-loop.github.com.git
  > rake generate
  > rake deploy
    输入用户名和密码,以后就能够在github上看到/octopress/public/下的东西了,要确保提交到的是master

5、文章发布

1. 发布前,先生成一MD文件

  > rake new_post['hello world']

在/source/_post/自动生成的MD文件名已经自动标准化

2. 新建页面

  > rake new_page['about']
  > rake generate
  > rake deploy

3. 如今能够经过xzh-loop.github.io访问博客了。

markdown语法请参考:http://wowubuntu.com/markdown/

 

 

——欢迎访问个人GitHub Pages: http://xzh-loop.github.io/, 近期会陆续把文章搬过去,也会对样式进行改进!

相关文章
相关标签/搜索