重装系统hexo博客重装

重装系统hexo博客重装

继重装系统后重装hexo,更新博客

标题安装hexo环境

1
2
3
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm

查看nodejs和npm版本号,验证是否安装完成

1
2
nodejs -v
npm -v

安装 Hexo

在原hexo博客目录下安装

1
sudo npm install -g hexo-cli

测试是否安装成功

1
hexo server

http://localhost:4000下查看服务器是否正常启动

关联github

参考博客
首先生成ssh秘钥

1
ssh-keygen -t rsa -C "youremail@example.com"

查看所生成的秘钥(其地址在上述创建命令后的有展示)

1
show '秘钥文件'

复制本地ssh秘钥到github上重新创建一个,然后检验

1
ssh -T git@github.com

显示下列文字代表关联成功

1
2
3
4
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? # 直接输入yes
Hi cnfeat! You've successfully authenticated, but GitHub does not provide shell access

然后就可以hexo g/hexo d

标题遇到的问题

关联秘钥成功后,hexo d报错:

1
2
3
4
5
6
fatal: LF would be replaced by CRLF in 2020/07/18/AVLTree/index.html
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Error: Spawn failed
at ChildProcess.<anonymous> (/mnt/d/git/git_tutorial/work/blog/hexo/node_modules/hexo-util/lib/spawn.js:51:21)
at ChildProcess.emit (events.js:315:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)

解决参考博客
运行下列命令后解决

1
git config --global core.autocrlf false

问题原因:

git在windows下,默认是CRLF作为换行符,git add 提交时,检查文本中有LF 换行符(linux系统里面的),则会告警。所以问题的解决很简单,让git忽略该检查即可