Skip to content

Instantly share code, notes, and snippets.

@runningdemo
Created September 30, 2013 16:52
Show Gist options
  • Save runningdemo/6766689 to your computer and use it in GitHub Desktop.
Save runningdemo/6766689 to your computer and use it in GitHub Desktop.
#setup

注意: 这篇文章假设你有GitHub账号以及了解基本的Git知识

页面访问地址: http://username.github.io/repository/

创建GitHub仓库

  // 拉取远程仓库至本地  
  git clone https://github.com/user/repository.git
  // 打开本地仓库
  cd repository

创建Orphan分支

  git checkout --orphan gh-pages
  
  // 如果你想要创建完全独立的页面可以执行:
  git rm -rf .

添加页面文件

git commit -a -m "Adding pages"

将gh-pages分支Push到GitHub仓库

git push origin gh-pages

使用自定义域名

如果你使用一级域名作为自定义域名:

  • 在gh-pages新建CNAME文件,格式为: yoursite.com
  • 添加A Record 并指向IP 204.232.175.78

如果你使用子域名作为自定义域名:

  • 在gh-pages新建CNAME文件,格式为: sub.yoursite.com
  • 添加新 CNAME record 指向 username.github.io

参考资料

Using GitHub Pages To Host Your Website

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment