安装nodejs
- 官网下载:https://nodejs.org/en/
- 安装
增加环境变量
不勾选
其他默认安装
安装git
- 官网下载:https://git-scm.com/
- 安装:全部默认下一步
下载hexo
右键左下角win图标,运行Windows powershell(管理员)(或者 cmd),输入:npm install hexo-cli -g
测试node,git和hexo是否安装成功
打开cmd运行:
1 | node -v |
显示版本号即安装成功
搭建github仓库
- 仓库名为:你的用户名.github.io
- 勾选add a readme file
本地生成博客文件
1 | hexo init # 初始化hexo博客 |
配置文件修改
1 | deploy: |
gitee是用于上传到gitee仓库,只使用GitHub可删除
下载hex-deployer插件用于上传文件
1 | npm instail hexo-deployer-git --save |
接下来就可以用hexo d上传文件至GitHub仓库
hexo d出现的错误
please tell me who you are
1
2git config --global user.email "用户名@gmail.com"
git config --global user.name "用户名"总是失败
hexo配置文件修改1
2
3
4
5deploy:
type: git
repository:
github: git@github.com:MarshVer/marshver.github.io.git //采用ssh方式hexo d
branch: master本地生成ssh公钥
1
ssh-keygen -t rsa
在GitHub的博客仓库中新建ssh密钥,密钥为本地C:\Users\zhu.ssh文件夹下id_rsa.pub的字符串(用记事本打开)
个人备份习惯
1 | hexo cl |
前三个用于上传.deploy_git到github的main;
后三个用于上传整个源文件夹到github的branch
更新hexo和hexo插件
1 | # 使用淘宝源的 cnpm 替换 npm |
恢复博客
安装git、nodejs、hexo等等。。
输入下列命令克隆博客本地文件
1
$ git clone https://github.com/marshver/marshver.github.io
在clone下来的那个文件夹里面执行
1
2
3
4
5npm install hexo-cli
npm install hexo-deployer-git
git config --global user.email "用户名@gmail.com"
git config --global user.name "用户名"本地生成ssh公钥
1
ssh-keygen -t rsa
在GitHub的博客仓库中新建ssh密钥,密钥为本地C:\Users\zhu.ssh文件夹下id_rsa.pub的字符串(用记事本打开)
最后可以执行如下代码就可以开始你的博客了
1
2
3hexo cl
hexo g
hexo d