大概流程
- 创建仓库,abcdkyd.github.io;
- 创建两个分支:master 与 hexo;
- 设置hexo为默认分支(因为我们只需要手动管理这个分支上的Hexo网站文件);
- 使用git clone git@github.com:abcdkyd/abcdkyd.github.io.git拷贝仓库;
- 在本地 abcdkyd.github.io 文件夹下通过Git bash依次执行npm install hexo-cli、hexo init、npm install 和 npm install hexo-deployer-git(此时当前分支应显示为hexo);
- 修改_config.yml中的deploy参数,分支应为master;
- 使用git init 、git remote add origin git@github.com:sylujia/sylujia.github.io.git以及git pull命令重新关联远端库。
- 使用git checkout hexo命令切换到hexo分支然后依次执行git add .、git commit -m “…”、git push origin hexo提交网站相关的文件;
- 执行hexo generate -d生成网站并部署到GitHub上。
GitHub
- 创建一个仓库,命名为 username.github.io GitHub Page类型为 User Pages
- 创建两个分支 master 和 hexo ,hexo为默认修改代码,master为发布代码
- 用 ssh 建立连接
1 | # ssh-keygen -t rsa -C "email@email.com" |
Hexo
-
需要安装 node.js
-
使用hexo在本地建站
1
2
3
4
5
6
7# npm install -g hexo-cli
# git clone git@github.com:abcdkyd/abcdkyd.github.io.git
# cd abcdkyd.github.io.git
# hexo init
# npm install
# hexo generate
# hexo server -
部署博客到GitHub上修稿配置文件 _config.yml 为:
1
2
3
4deploy:
type: git
repository:git@github.com:abcdkyd/abcdkyd.github.io.git
branch: master
上传和部署
1 | # npm install hexo-deployer-git —save //安装部署的插件 |
提交到hexo分支,由于上面执行了hexo init 命令,所以要重新关联远程库
1 | # git init |
更换主题
如果想要使用其他主题,可以使用git clone将别人的主题拷贝到H:\sylujia.github.io\themes下,然后将_config.yml中的theme: landscape改为对应的主题名字。
1 | # git clone https://github.com/iissnan/hexo-theme-next.git themes/next |
常用命令
1 | hexo new "postName" #新建文章 |