GitHub pages for personal site. How to deploy a folder

﹥>﹥吖頭↗ 提交于 2019-12-06 03:36:11

Depending of repository kind your using, a User/Organization (UO) site or a Project site (P), sources and pages will be versionned in :

  • User/Organization - sources : sources, pages: master
  • Project - sources : master, pages: gh-pages

Note: The pages branch is mandatory, but the sources branch name can be changed.

Setup

  • Initialize an empty github repository : github.com/userName.github.io for UO or github.com/repositoryName for P

Locally, initialize your local repository :

  • Go to source folder cd /home/username/www/yoursite or anything you want
  • git init
  • git remote add origin git@github.com:userName/userName.github.io.git (UO) or git remote add origin git@github.com:userName/repositoryName.git (P)
  • git checkout -b sources (UO) or git checkout master (P)
  • in your .gitignore add your dist/public. As you are currently on master we will ignore it an version it in an other branch
  • git add -A
  • git commit -m "base sources". You now have committed your sources.
  • git push origin sources (UO) or git push origin master (P) push your sources in the appropriate branch
  • cd dist/public
  • touch .nojekyll, this file tells gh-pages that there is no need to build a Jekyll site
  • git init
  • git remote add origin git@github.com:userName/userName.github.io.git (UO) or git remote add origin git@github.com:userName/repositoryName.git (P)
  • git checkout master (UO) or git checkout -b gh-pages (P) put this repository on the appropriate branch
  • your grunt task here
  • git add -A
  • git commit -m "first build" commit your site code
  • git push origin master (UO) or git push origin gh-pages (P)

You now have pushed your code and pages in two different branches. They will now be pushed depending on where you are :

pushing sources

  • cd yourWorkingDirestory
  • git add -A
  • git commit -m "your commit message"
  • git push origin sources (UO) or git push origin master (P)

pushing pages

  • cd yourWorkingDirestory/dist/public
  • git add -A
  • git commit -m "your commit message"
  • git push origin master (UO) or git push origin gh-pages (P)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!