github page的兩種類型


 1. 什麼是Github ?php


Github 官方主頁css

簡單說,Github是一個基於git的社會化代碼分享社區。html


你能夠在Github上建立免費的遠程倉庫(remote repository),分享你的代碼,固然也能夠關注其餘人的代碼python

你也能夠創建公司帳戶,建立私有的遠程倉庫,與開發團隊共同協做開發git

想要使用Github Pages,你首先要建立一個Github帳戶github

2. 誰在使用Github免費託管網站 ?web


Bootstrapbootstrap

NODESCHOOLruby

WebComponents網站

......

3. Github pages的兩種類型


3.1 Project Pages(Repository Pages)


URL for Project Pages.png

在Github上咱們能夠給不一樣的project分別建立相應的repository,對於某一個repository,你能夠在其中建立一個小網站,向人們展現你的項目,提供項目的相關信息等等。這就是所謂的project pages。例如上面說的bootstrap.com

在一個repo的gh-pages分支中的全部文件將出如今github.io上。

Project Pages How-To

建立一個gh-pages分支

編輯相應的html/css/js文件,用於展現在github.io上

push gh-pages分支到Github上面

//下面是一些會用到的git command

git checkout -b gh-pages //create a gh-pages branch 

git branch //check all branches and which branch you are currently working on

git push origin gh-pages //push gh-pages branch to github

git checkout --orphan go-pages //you can create a new empty branch

git push origin :gh-pages //delete a remote branch

最簡單地方法是從Github上直接自動生成頁面,還能夠選擇模板。移步這裏

3.2 User Pages


URL for User Pages

每個Github帳戶只能有一個User Pages,主要用來展現一個帳戶中最最重要的項目。


命名爲username.github.io的repo中的內容將會出如今username.github.io上。


User Pages How-To


建立一個新的repo,名字必須是username.github.io



建立新的repo

建立你的網站,包括:HTML文件,CSS文件...


my_website_folder

    |- index.html

    |- main.css

    |- bootstrap.js

    |...

建立本地git repo

~ $ cd my_website_folder //進入你的網站所在的文件夾

~ $ git init

~ $ git add .

~ $ git commit -m "Initial commit"

添加remote repo到本地,push到Github

~ $ git remote add origin https://github.com/Jason-Yuan/Jason-Yuan.github.io.git

~ $ git remote -v //能夠查看是否添加成功,及其詳細信息

~ $ git push origin master

設置個性域名

建立一個CNAME文件,包含你的個性域名,放在source文件夾下

example.com

把你個性域名的A record指向Github DNS

192.30.252.153

192.30.252.154

若是想要搭建博客,下面列了一些很是流行的framework,可自動生成靜態頁面:

Octopress (基於Ruby)

Jekyll (基於Ruby) - 經過Github Pages和Jekyll搭建我的博客

Hexo (基於NodeJS) - 經過Github Pages和Hexo搭建我的博客

Pelican (基於Python)

4. Github Pages的限制(Limitations)


Github Pages只是靜態網站(HTML, CSS, JavaScript)

沒有服務端,因此不支持服務端的語言(沒有ruby, php, python)

相關文章
相關標籤/搜索