Github Pages

来源:互联网 发布:手机硬件检测软件 编辑:程序博客网 时间:2024/05/21 21:27

https://pages.github.com/
提供一个挂载静态页面的站点

基础用法

  • 新建一个名为
    username.github.io的Repository
    例如:
    我的github账号是
    yyecust
    就新建一个
    yyecust.github.io仓库

  • 把这个仓库clone下来 加一个index.html 再push回去

  • 可以使用页面生成器生产一个漂亮的主题
    参考
    https://help.github.com/articles/creating-pages-with-the-automatic-generator/
  • 不止一个网页文件的话
    直接写html然后Push就好了
    比如写一个test.html
    就可以在 https://yyecust.github.io/test.html访问到
  • 可以建一个test的文件夹,然后在test里面间index.html
    这样就可以把.html省略掉了

jekyll

GitHub Pages提供了一个叫jekyll来更好的构建站点
jekyll使用Ruby
官网:http://www.ruby-lang.org/zh_cn/
Windows安装包:http://rubyinstaller.org/
安装时会有提示添加到环境变量 务必不要取消勾选

gem是Ruby的包管理工具,会自动安装好
在终端中

gem install jekyll bundler

会装好这两个包
cd到github pages 那个目录
jekyll new .
会在当前生成 jekyll
再执行Bundle

~/myblog $ bundle install~/myblog $ bundle exec jekyll serve# => Now browse to http://localhost:4000

就可以看到效果了

如果想完整了了解jekyll
bootcss很良心的提供了翻译
http://jekyll.bootcss.com/
当然这不是最新的

装了jekyll有何好处呢?
提供了简单的路由功能
原来
/test.html的页面
输入
/test也可以访问

挂载项目介绍页面

  • 在项目Master分支下新建一个docs目录
  • 在目录里写项目介绍网页
  • git push
  • 在项目主页面中进入Setting,在GitHub Pages下选择 master branch /docs folder
0 0