简介
其实我以前就弄好了的。。。谁知道换电脑之后又要重新配置。。。
不过我的博客文件都有云盘备份,因此博客文件都在,因此只需要重新配置环境
Heox总结
主题众多,配置githubPage也不会很麻烦
每次写一篇写博客都需要Hexo new \clean\g\d。。。。。大批量导入md嘛。。还没学会
安装准备
- Git
- Node.js
怎么安装最新版不描述,Node.js保持默认加入环境变量即可,两个软件的安装位置都可以变,其它选项保持默认即可
配置Git
user
打开git bash,查看当前用户配置
$ git config user.name
$ git config user.email
$ git config --global --list
由于我安装之后还没有配置过,因此返回结果为空
下面开始配置,需要将名称(Kearney)和邮箱进行替换啊
$ git config --global user.name "Kearney"
$ git config --global user.email "1asdas2@qq.com"
此时再用git config --global --list
就可以查看用户配置信息了。
SSH
检查
在git Bash中查看之前有没有密钥
$ cd ~/.ssh
bash: cd: /c/Users/Kears/.ssh: No such file or directory
不存在该文件很正常,新电脑我还没有设置ssh(记得删除Github上的旧SSH)
生成和配置
下面开始生成SSH密钥公钥,替换邮箱后一直回车即可
$ ssh-keygen -t rsa -C "1asdas2@qq.com"
查看和复制公钥
$ cat ~/.ssh/id_rsa.pub
打开Github的Setting-SSH,Add new ssh
Ttitle输入这个ssh的标题,比如 柯南的Mac
公钥就粘贴在下面的大框框里面,确认后输入密码再次确认即可
测试
(码云的用户可以这样测试$ ssh -T gitee@gitee.com
,其它一样)
$ ssh -T git@github.com
回车后会显示
The authenticity of host ‘github.com (13.250.177.223)’ can’t be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
输入yes回车即可,测试成功的话会提示
Hi 柯南! You’ve successfully authenticated, but GitHub does not provide shell access.
删冗余文件
进入博客文件夹中,删除node_modules、 public、 .git 、.deploy_git
只需保留**_config.yml**,themes/,source/,scaffolds/,package.json,.gitignore
安装Hexo
打开Git Bash,输入
$ npm install hexo-cli -g
git init
git remote add origin git@github.com:BackMountainDevil/BackMountainDevil.github.io.git
npm install
hexo clean
hexo g
hexo s
clean和g都可以完美运行,就是s本地服务的时候,浏览器访问http://localhost:4000/没啥结果显示。。。
Conclusion
重建以失败告终,罢了罢了,换一个其它的生成器试一试,保留source下的md文件即可。然后卸载hexo、npm
$ npm uninstall hexo-cli -g
$ npm uninstall hexo
卸载npm就很简单啦,程序管理