1.创建github帐号,新建一个以用户名.github.io
命名的仓库
2.安装git,创建ssh12345ssh-keygen -t rsa -f ~/.ssh/id_rsa_github#用于创建ssh,会有公钥和私钥,将公钥中的内容拷贝到github帐号 Settings > SSH and GPG keys 中ssh -T git@github.com#用于测试是否成功
输入yes,其他使用默认即可,配置git12git config --global user.name "cnfeat"//用户名git config --global user.email "cnfeat@gmail.com"//邮箱
3.下载并安装hexo
4.新建一个目录用于放置本地博客12345678mkdir hexocd hexonpm install hexo-cli -g hexo init blogcd blognpm installhexo ghexo s #可以在本地http://localhost:4000/查看
5.修改blog目录下的_config.yml文件中的deploy:1234deploy:type: gitrepository: git@github.com:xxxxxx/xxxxxxx.github.io.gitbranch: master
6.安装hexo中关于git的组件,上传部署(需要cd到hexo\node_modules\hexo\Hexo目录)12345npm install hexo-deployer-git --savehexo cleanhexo ghexo d
如果出现问题请参考使用hexo d无法上传问题解决办法然后再使用以上代码
参考: