Github Blog 搭建手册

原文: http://www.ilehao.com/blog/2012/11/11/github-blog-config/
很多人都希望拥有一个属于自己的免费blog空间。

之前也会在一些技术论坛写blog,但是总觉得那是不属于自己的网站。

现在github给我们一个机会,可以搭建自己的独立博客。

在github上搭建博客可以利用Jekyll或者Octopress, Octopress是在Jekyll上建立起来的,即使没有网站设计经验的人也能够快速搭建自己的博客。

Jekyll和Octopress都是利用Ruby实现的,因此在搭建自己博客的过程中难免要接触到一些Ruby的东西。当然,这也许可以让你开始对Ruby感兴趣,并深入学习之。

现在来简单介绍下Window下搭建blog实施步骤:

*在www.github.com网站上注册一个帐户,并创建你blog站点的repository [username.github.com].

*下载git,安装完成后就可以在本地使用git了,然后在本机使用git创建SSH Key。

ssh-keygen -C "useremail" -t rsa

备注: useremail为你注册github用户时的邮箱地址 这时,在系统目录下就会生成一个.ssh文件夹,里面为对应的SSH Key,其中id_rsa.pub是Gighub需要的SSH公钥文件。 将id_ras.pub文件里内容拷贝到Github的Account Settings里的key中。 这样你就可以直接使用Git和Github了.

*安装Ruby环境 ** 下载RubyInstaller和DevKit,并安装,然后进行到DevKit目录下,运行以下命令

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

安装成功后,就可以使用一些Ruby的小工具了。

*安装OctoPress 通过Git从Github上克隆一份Octopress

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

安装一些依赖的工具

cd octopress
gem install bundler
bundle install

安装Octopress默认的Theme

rake install

通过_config.yml来配置博客

创建一个博客 rake new_post["title"] 创建一个博客目录 rake new_page["page"] 预览效果:
rake generate
rake preview

然后在浏览器中打开http://localhost:4000,就可以看到效果了。

*将博客部署到Github上 通过rake setup_github_pages命令,将自己的Blog与你在Github创建的repository关联起来。在过程中根据提示输入username.github.com 然后再通过下面命令来把博客内容部署到Github上 rake deploy git status ##查看更新状态 git add . ##把当前目录上所有的变更加上 git commit -a -m ‘commit’ git push origin source

在浏览器中输入username.github.com就可以看到你的博客内容了
** 常见问题 乱码,请设置
LC_ALL=zh_CN.UTF-8和LANG=zh_CN.UTF-8

猜你喜欢

转载自maker-chen.iteye.com/blog/1746931