创建Github Pages

一个Github用户可以存在多个Github Pages每个项目都可以有自己的Github Pages, 在项目的 setting > github pages 中进行设置

Github Pages访问路径为 https://username.github.io/project

若是项目名为 username.github.io 为主页项目, 则访问路径为 https://username.github.io

创建好后无需在其中添加任何文件, 待之后 git push 即可

安装Nodejs

下载

安装Hexo

1
$ npm install -g hexo-cli

创建Hexo文件

1
2
3
$ hexo init <folder>
$ cd <folder>
$ npm install

几个常见的Hexo命令

1
2
3
4
5
6
7
8
9
10
11
//新建文章 生成的文章在source文件夹下
$ hexo n "hello"

//构建 生成html
$ hexo g

//清除已生成的文件
$ hexo clean

//本地预览
$ hexo s

提交至Git

打开根目录下的_config.yml文件

1
2
3
4
5
6
7
8
9
10
11
12
//github page的访问地址
# url: https://github-laziji.github.io
url: https://github-laziji.github.io/lllblog

# root: /
root: /lllblog/

//repo 从你新建的项目中复制过来
deploy:
type: git
repo: git@github.com:GitHub-Laziji/lllblog.git
branch: master

最后提交至github

1
$ hexo d

可以看到项目已经提交了, 访问 https://username.github.io/project 即可看到你的博客了