Github Pages + Jekyll 独立博客快速搭建&上线指南

1 、新建一个 Repository(仓库)

2、安装git bash

3、正式使用

对已有项目进行git初始化

到jekyll项目下,运行命令:

$ git init

创建一个名为gh-pages的分支

$ git checkout --orphan gh-pages

Jekyll官网的github pages介绍上说如果要部署在github上,必须名称叫gh-pages。所以先创建一个叫gh-pages的分支

发布

使用命令:

$ git add .
 $ git commit -a -m "v0.0.1 first blood"

提交所有的修改到本地的git仓库

上传到github

使用命令:

$ git remote add origin https://github.com/(github用户名)/(jekyll项目名称).git
 $ git push origin gh-pages

修改后提交

使用命令:

$ git add .
 $ git commit -a -m "自己的提交注释"
 $ git push origin gh-pages

第一句增加所有新增的文件到项目中

第二句提交所有修改

第三句将修改提交到远程github服务器

预览效果:https://github用户名.github.io/项目名/


新换电脑后更新代码操作:

1、git 客户端 git clone

2、git pull 把代码下到本地

3、切换分支 git checkout -b gh-pages origin/gh-pages

4、本地修改文件

5、提交

$ git add .

git commit -m "add new blog"

git commit -m "add new blog"

绑定到自己的域名

如果是绑定到一级域名:
1. 首先在项目根目录下创建一个叫CNAME文件,里面写上自己的以及一级域名(如这个博客就是skyinlayer.com)
2. 在DNS中为自己的域名增加一条A记录,指向207.97.227.245
3. 将项目提交到github上,等一会儿(不会超过1小时)
4. baseurl应该为"/"
5. 访问自己的域名看看结果吧

如果是绑定到二级域名,需要额外在DNS中增加一条CNAME,指向(github用户名).github.io,然后再CNAME文件中修改为自己的二级域名即可




参考网站

https://segmentfault.com/a/1190000000406019

http://os.51cto.com/art/201409/450260.htm

http://www.tuicool.com/articles/ruMVjyN
http://playingfingers.com/2016/03/26/build-a-blog/
http://www.tuicool.com/articles/RZbEV3

你可能感兴趣的:(Github Pages + Jekyll 独立博客快速搭建&上线指南)