本博客的搭建方法

省流:Hexo框架 + Butterfly主题搭建博客

搭建方法主要参考:

https://butterfly.js.org/posts/21cfbf15/

https://nickxu.me/2022/02/13/Hexo%20+%20Butterfly%20%E5%BB%BA%E7%AB%99%E6%8C%87%E5%8D%97%EF%BC%88%E4%B8%80%EF%BC%89Hexo-%E6%A1%86%E6%9E%B6/

//初始化Hexo
hexo init MyBlog

@_config.yml配置文件
//修改基本信息,部署网址位置,这里我选择部署到github pages上(因为免费x

//安装hexo框架中的git部署
npm install hexo-deployer-git --save

*至此可以在公网上部署博客了,虽然是最基本的格式

//安装butterfly主题
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly

//安装渲染器插件
npm install hexo-renderer-pug hexo-renderer-stylus --save

*至此可以实现butterfly主题的博客

报错1:

image-20240830140436370

虽然只是个警告,但是这个警告表示找不到页面,到时候会打不开页面的,导致报错的原因是在主配置文件中将主题改成了butterfly(theme: butterfly),但是在theme文件夹里没有butterfly的原因

报错2:

image-20240830142055295

出现这个错误的原因只是因为没有安装渲染器插件,所以无法渲染页面而已(废话x

报错3:

image-20250712102419368

ERROR
TypeError: D:\MyBlog\themes\butterfly\layout\includes\header\post-info.pug:47
45| i.far.fa-file-word.fa-fw.post-meta-icon
46| span.post-meta-label= _p('post.wordcount') + ':'
> 47| span.word-count= wordcount(page.content)
48| if theme.wordcount.min2read
49| span.post-meta-separator |
50| if theme.wordcount.min2read

wordcount is not a function
at eval (eval at wrap (D:\MyBlog\node_modules\pug-runtime\wrap.js:6:10), <anonymous>:449:57)
at template (eval at wrap (D:\MyBlog\node_modules\pug-runtime\wrap.js:6:10), <anonymous>:5640:7)
at _View._compiled (D:\MyBlog\node_modules\hexo\dist\theme\view.js:120:67)
at _View.render (D:\MyBlog\node_modules\hexo\dist\theme\view.js:37:21)
at D:\MyBlog\node_modules\hexo\dist\hexo\index.js:60:29
at tryCatcher (D:\MyBlog\node_modules\bluebird\js\release\util.js:16:23)
at D:\MyBlog\node_modules\bluebird\js\release\method.js:15:34
at RouteStream._read (D:\MyBlog\node_modules\hexo\dist\hexo\router.js:43:9)
at Readable.read (node:internal/streams/readable:737:12)
at resume_ (node:internal/streams/readable:1255:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

打开博客也是一片空白。我生成的html文件内容全为空

初步推断是

wordcount:
enable: true
post_wordcount: true
min2read: true
total_wordcount: true

这里缺少字数统计这个功能报错,导致后续页面的生成失败

未安装hexo-wordcount插件

npm install hexo-wordcount --save

安装之后重新生成一下就行了

hexo c && hexo g && hexo d