Hexo配置过程中遇到的坑及解决方法

1、ssh -T git@github.com出现Permission denied (publickey)

在创建执行ssh-keygen命令之后,会让你输入一个文件名(yourfilename)来保存key。
此时的文件名需要.ssh/文件夹里文件名相同,如下面的id_rsa。

1
2
3
$ ssh-keygen -t rsa -C "xxxxxxx@xx.xxx"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/xxx/.ssh/id_rsa):yourfilename

方案一:直接将yourfilename设置为id_rsa

使用方案一时应当cd到~/.ssh/,否则需要生成后将文件移动到~/.ssh/目录下

方案二:可以将新建的文件添加到.ssh/

1
ssh-add ~/.ssh/yourfilename

设置完毕后,.ssh/文件夹里面需要有三个文件:id_rsa, id_rsa, known_hosts
之后执行

1
ssh -T git@github.com

就可以看到期望的效果了

2、hexo g后FATAL bad indentation of a mapping entry 错误1

1
2
3
4
5
6
FATAL bad indentation of a mapping entry at line 100, column 9:
repo: git@github.com:xxx/xxx.g ...
^
YAMLException: bad indentation of a mapping entry at line 100, column 9:
repo: git@github.com:xxxx/xxx.g ...
^

注意”^”的位置
这是因为在_config.yml文件中设置站点时的缩进问题,

1
2
3
4
deploy:
type: git
repo: git@github.com:tcnull/tcnull.github.io.git
branch: master

正确缩进应为:

1
2
3
4
deploy:
type: git
repo: git@github.com:tcnull/tcnull.github.io.git
branch: master

type, repo, branch应当对齐。

3、hexo g后FATAL bad indentation of a mapping entry 错误2

1
2
3
4
5
6
FATAL bad indentation of a mapping entry at line 100, column 9:
repo: git@github.com:xxx/xxx.g ...
^
YAMLException: bad indentation of a mapping entry at line 100, column 9:
repo: git@github.com:xxxx/xxx.g ...
^

注意”^”的位置
出现这种情况时空格问题,冒号后面都需要一个空格,如下:

1
2
3
4
deploy:
type: git
repo: git@github.com:tcnull/tcnull.github.io.git
branch: master

4、关于部署之后的404问题

本地测试没问题,也成功上传到github, 还是出现404

首先在github上面创建仓库是需要将权限设置为public,而不是private,
否则将出现404错误。

github上的repository的命名

格式必须是yourname.github.io这种。其次yourname必须是你的github的用户名,
否则将出现404错误。