1、下载并安装git
2、下载并安装nodejs
3、安装配置hexo
如果提示没有npm命令,则是nodejs的npm环境变量没有配置,安装nodejs的时候选择默认配置环境变量即可。
1
npm install -g hexo
初始化hexo
1
hexo init
配置_config.yml和主题安装详见其它文章
1
2hexo n firstblog #新建文章
hexo new page firstpage #新建页面
4、配置GitHub
- 如果没有github账户请先创建;
- 点击右上角加号,选择New repository
- 填写yourname.github.io,例如qicunshang.github.io,点击创建
- 记住仓库地址,并点击setting找到Github pages设置主题
5、GitHub和Hexo建立联系
打开git bash here,设置git的username和email
1
2git config --global user.name "qicunshang"
git config --global user.email "lsreal@qq.com"生成秘钥以便ssh登录上传代码
1
ssh-keygen -t rsa -C "lsreal@qq.com"
遇到Enter file in which to save the key (/c/*/.ssh/id_rsa): 直接回车
提示输入两次passphrase,可以为空
- 秘钥生成之后会创建id_rsa、id_rsa.pub文件
- 点击用户中心setting页面的SSH and GPG keys,然后选择New SSH Key,title随便写,key填id_rsa.pub文件的内容即可
- 配置_config.yml的Deployment部分,修改:
1
2
3
4deploy:
type: git
repo: git@github.com:qicunshang/qicunshang.github.io.git
branch: master
注意repo修改为自己的仓库地址
- 安装扩展
1
npm install hexo-deployer-git --save
如果没有安装可能会提示ERROR Deployer not found: git
- 生成、部署
1
2hexo g #生成
hexo d #部署
部署成功即可通过youname.github.io查看你的博客了!