一直都想搭建一个博客,今天终于把博客给初步搭建好了。搭建的过程其实不那么顺利,所以简答记录一下。

搭建过程

  • 根据手把手搭建博客教程这篇文章来进行搭建,其中目前只看了它的第一页
  • 后期在hexo主题里面选择了even主题
  • 依照even-wiki来添加标签、分类和about页面
  • 修改主题目录下的_config.yml的menu,把home、tags等手动改成中文了

遇到的坑

  • 没有看wiki,自己去谷歌建立tags、categories等页面
  • 建立好tags,却在tags页面没有看到相应的标签。是因为没有为tags/index.md设置layout为tags
  • 中文语言,在站点目录下的_config.yml中设置language: zh-cn

博客重新搭建

配置及源文件

因为经常重装系统,所以博客也需要重新恢复。先配置git相关信息

1
2
3
4
5
6
7
git config --global user.name "plmsmile"
git config --global user.email "pulimingspark@163.com"
ssh-keygen -t rsa -C "pulimingspark@163.com"
# 去GitHub上添加sshkey
cat ~/.ssh/id_rsa.pub
# 完成后,进行测试
ssh -T git@github.com

然后把之前的PLMBlogs拷贝到D盘,一般目录是d/PLMBlogs

1
2
3
4
5
6
7
cd PLMBlogs
# 安装hexo
npm install hexo-cli -g
# 安装插件
npm install hexo-deployer-git --save
# 安装依赖
npm install

数学公式渲染

执行完上面的操作后,执行如下

1
2
3
4
hexo clean
hexo generate # 这一步会报错
hexo server
hexo deploy

错误信息如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: write EPIPE
at exports._errnoException (util.js:1020:11)
at Socket._writeGeneric (net.js:711:26)
at Socket._write (net.js:730:8)
at doWrite (_stream_writable.js:331:12)
at writeOrBuffer (_stream_writable.js:317:5)
at Socket.Writable.write (_stream_writable.js:243:11)
at Socket.write (net.js:657:40)
at Hexo.pandocRenderer (D:\PLMBlogs\node_modules\hexo-renderer-pandoc\index.js:64:15)
at Hexo.tryCatcher (D:\PLMBlogs\node_modules\bluebird\js\release\util.js:16:23)
at Hexo.ret (eval at makeNodePromisifiedEval (C:\Users\PLM\AppData\Roaming\npm\node_modules\hexo-cli\node_modules\bluebird\js\release\promisify.js:184:12), <anonymous>:13:39)
at D:\PLMBlogs\node_modules\hexo\lib\hexo\render.js:61:21
at tryCatcher (D:\PLMBlogs\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (D:\PLMBlogs\node_modules\bluebird\js\release\promise.js:512:31)
at Promise._settlePromise (D:\PLMBlogs\node_modules\bluebird\js\release\promise.js:569:18)
at Promise._settlePromiseCtx (D:\PLMBlogs\node_modules\bluebird\js\release\promise.js:606:10)
at Async._drainQueue (D:\PLMBlogs\node_modules\bluebird\js\release\async.js:138:12)
at Async._drainQueues (D:\PLMBlogs\node_modules\bluebird\js\release\async.js:143:10)
at Immediate.Async.drainQueues (D:\PLMBlogs\node_modules\bluebird\js\release\async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
events.js:160
throw er; // Unhandled 'error' event
^

Error: spawn pandoc ENOENT
at exports._errnoException (util.js:1020:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)

原因是有大量的数学公式,所以需要对网页进行渲染。

一般是使用pandoc进行渲染,先去官网下载,然后下一步安装即可。最后,执行下面的命令,安装就好了。

1
2
3
npm install hexo-renderer-pandoc --save
# 再次应该就不会报错了
hexo generate

配置git

1
2
3
4
5
6
7
8
git config --global user.name plmsmile
git config --global user.email plmspark@163.com
# 生成Key,一路回车
ssh-keygen -t rsa -C "plmspark@163.com"
cat ~/.ssh/id_rsa.pub
# 到github上添加该sshkey
# 测试
ssh -T git@github.com

潜在问题

  • 本站没有搜索功能,安装插件失败了
  • tags页面,标签数量错误

期望

  • 认真学习
  • 好好做笔记
  • 要更新博客
  • 自己常来看看之前的知识点