郭心全

IT者,程序员,在读硕士研究生

搭建博客问题总结

前言

经过了好多天,终于有点进展了,好歹显示了个页面,这个菜需要慢慢来进步啊
下面我来记录下自己搭建博客、更换主题、写第一篇博客遇到的问题,与诸君共勉

来吧,看我这菜鸟遇到的问题

Pro1

FATAL can not read an implicit mapping pair; a colon is missed at line 86, colum
n 16:
branch:master

原因:没有加空格,master和branch:之间一定要加空格,且type: repo: branch:后面都有空格

空格

#### Pro2
$ hexo deploy
ERROR Deployer not found: gi

原因:没有这个文件
解决办法:
$ npm install –save hexo-deployer-git

Pro3

$ hexo deploy *** Please tell me who you are.

原因:创建git文件时信息不完善
解决办法:
git config –global user.email “you@example.com“ git config –global user.name “Your Name”

Pro4

git init时出错

$ git init Initialized empty Git repository in E:/MyBlog/.git/

解决办法:
$ unset SSH_ASKPASS

Pro5

npm install hexo-deployer-git
npm WARN deprecated swig@1.4.2: This package is no longer maintained

原因:国外镜像访问不到了,试着切换到国内镜像,国内较好的NPM有CNPM和淘宝的NPM源比较稳定,我用的淘宝的
npm config set registry https://registry.npm.taobao.org
npm install hexo-deployer-git

Pro6

$ ssh-add gxq_ssh_key Could not open a connection to your authentication agent

原因:没有启动ssh agent
解决办法:1.输入如下命令,启动agent

eval $(ssh-agent -s) 或者 eval ssh-agent -s

其中,`是~键上的那个

Pro7

$ git commit

之后进入vim编辑,此时处于不可编辑状态,点击字母C键可进入编辑状态,按Esc键,再连着按两次大写字母Z即可退出Vim

Pro8

git deploy 部署到GitHub上出现错误如下

To github.com:JadenFK/JadenFK.github.io.git
![remote rejected] HEAD -> master (push declined due to email privacy restrictions)
error: failed to push some refs to 'git@github.com:JadenFK/JadenFK.github.io.git’
FATAL Something’s wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: remote: error: GH007: Your push would publish a private email address.
remote: You can make your email public or disable this protection by visiting:
remote: http://github.com/settings/emails
To github.com:JadenFK/JadenFK.github.io.git
! [remote rejected] HEAD -> master (push declined due to email privacy restrictions)
error: failed to push some refs to 'git@github.com:JadenFK/JadenFK.github.io.git’
at ChildProcess. (E:\MyBlog\node_modules\hexo-util\lib\spawn.js:37:17)
at ChildProcess.emit (events.js:182:13)
at ChildProcess.cp.emit (E:\MyBlog\node_modules\cross-spawn\lib\enoent.js:40:29)

解决办法:seting->emails->keep my email address private,不勾选

Pro9

b_mBlank
第一个JadenFK与github用户名一样,JadenFK.github.io必须是repositories的名字,就是new depositor时输入的名字。如下图:deploy

Pro10

clone主题,进入要clone的主题的GitHub用户的Repositories,点击要进入的主题,绿色图标”Clone or download”,拷贝期地址,如图:
theme_address
然后再Git Bash终端,自己建立的博客文件夹下,输入git clone 主题仓库地址 themes/主题名字。
主题名字就是.com后面的那个,比如我clone的是这个wizicer

$ git clone https://github.com/wizicer/IcerSite.git themes/wizicer

接下来就是自动下载:

themedownload
然后打开_config.yml,把theme改成自己要的主题如下:
renametheme
我把这里的landscape改为wizicer,接下来输入hexo clean,来清理缓存,然后hexo g -d 重新生成博客并且部署。

Pro11

错误:

WARN No layout: index.html

因为clone的博客模板没有layout.啊。。。。。。。。。。

Pro12

图片不显示问题。。。。。。。。。。。。卡了我好久
解决:代码要顶格写,否则不显示,如下
picturesave
改为:
display_picture
其中,我还参考了博客:
https://www.jianshu.com/p/3db6a61d3782 ,修改了hexo-asset-image插件,我是直接安装修改好的。