用Octopress在GitHub发布博客
用Octopress在GitHub发布博客
Octopress可以配合github或者heroku使用。Github还是最方便的,用户可以有无限的public空间。
配置Octopress前准备github
- 注册github账号
- 建一个新的repository。
- 如果是github主站,域名是
username.github.io
, 那么repository的名字就是username.github.io
。 - 如果不是主站,而是项目页(gh-pages),域名是
https://username.github.io/repository_name
, 那么repository的名字就是repository_name
。
- 如果是github主站,域名是
配置Octopress
1
|
|
这个命令会:
- 问你github的url。
- 如果是github主站,域名是
username.github.io
, 那么输入git@github.com:username/username.github.io.git
。 - 如果不是主站,而是项目页(gh-pages),域名是
https://username.github.io/repository_name
, 那么输入http://username.github.io/repository_name
。
- 如果是github主站,域名是
Rename the remote pointing to imathis/octopress from ‘origin’ to ‘octopress’Add your Github Pages repository as the default origin remote.Switch the active branch from master to source.Configure your blog’s url according to your repository.Setup a master branch in the _deploy directory for deployment.
新建博文
1
|
|
这样就会产生一个source/_posts/日期-title.markdown的markdown文件。只要用markdown的语法写博文就可以了。
写完以后,就可以发布博文了。
预览博文
1
|
|
这个命令会把markdown的页面翻译成_deploy/
文件夹下的html页面。
1
|
|
这个使你可以在本地预览博客页面。运行后,在浏览器打开http://localhost:4000/
就可以看到你的页面了。
发布博文
1
|
|
这个会把博文发布到github。这里用了超级用户权限,因为有时候会有权限问题。
然后就可以到username.github.io
或者https://username.github.io/repository_name
查看你的博客了。
还有一个简化命令
1
|
|
就是rake generate
和rake deploy
的结合。