「小明の雜貨鋪」搭建記錄存檔
1 | hexo clean && hexo g && gulp && hexo d |
1 | hexo clean && hexo s |
从零开始
主题安装
https://butterfly.js.org/posts/21cfbf15/
1 | git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly |
安装
1 | npm install hexo-renderer-pug hexo-renderer-stylus --save |
修改 Hexo 根目录下的 _config.yml,
1 | theme: butterfly |
在 hexo 的根目錄創建一個文件 _config.butterfly.yml,並把主題目錄的 _config.yml 內容複製到 _config.butterfly.yml 去。
域名
1 | deploy: |
abbrlink(在写第一篇博客前修改)
https://zhuanlan.zhihu.com/p/169492685
1 | npm install hexo-abbrlink --save |
修改 _config.yml
1 | permalink: posts/:abbrlink.html # 此处可以自己设置,也可以直接使用 :/abbrlink |
使用 gulp 压缩博客静态资源
1 | npm install --global gulp-cli # 全局安装 gulp 指令集 |
为 Gulp 创建 gulpfile.js 任务脚本。在博客根目录下新建gulpfile.js,打开并输入以下内容:
1 | // 用到的各个插件 |
更新所有插件
1 | npm update |
中英文之间自动加空格
1 | npm install hexo-filter-auto-spacing --save |
1 | auto_spacing: |
标签外挂
https://akilar.top/posts/615e2dec/
1 | npm install --save hexo-pdf |
在 source 文件夹下创建一个叫 pdf 的文件夹,把 xxx.pdf 文件放在这里,然后在使用
1 | {% pdf /pdf/xxx.pdf %} |
LATEX
1 | npm un hexo-renderer-mathjax --save |
进入 主题 目录,编辑 _config.yml:
1 | # MathJax Support |
在 根目录 _config.yml 的末尾添加
1 | markdown: |
字數統計
1 | npm install hexo-wordcount --save |
1 | wordcount: |
隱藏文章
將來的文章
_config.yml中# Writing板塊置future: false,若發佈時間晚於當前時間,則不會顯示,在重新部署後顯示。發佈狀態
文章開頭置
published: false。首頁隱藏
執行 $ npm uninstall hexo-generator-index,
執行 $ npm install hexo-generator-indexed,
文章開頭置 hide: true;
在 _config.yml 中 hide_categories 可設置隱藏某個分類下的文章。
草稿
_config.yml中# Writing板塊置render_drafts: false,使用
$ hexo new draft <title>新建草稿,使用
$ hexo s --draft預覽,使用
$ hexo publish <title>發佈草稿(或直接從source/_drafts移動到source/_posts文件夾)隱藏文件夾
在
_post文件夾中新建_<folder>文件夾,裏面的文件不會被發佈。加密
執行
$ npm --save hexo-blog-encrypt,文章開頭置
1
2
3
4
5password: <password>
abstract: This blog is encrypted.
message: Please enter the password.
wrong_pass_message: Incorrect password, please try again.
wrong_hash_message: Bug found!或在
_config.yml中添加1
2
3
4
5
6
7
8
9
10encrypt: # hexo-blog-encrypt
password: <password>
abstract: This blog is encrypted.
message: Please enter the password.
tags:
- {name: <tag>, password: <password>}
- {name: <tag>, password: <password>}
template: <div id="hexo-blog-encrypt" data-wpm="{{hbeWrongPassMessage}}" data-whm="{{hbeWrongHashMessage}}"><div class="hbe-input-container"><input type="password" id="hbePass" placeholder="{{hbeMessage}}" /><label>{{hbeMessage}}</label><div class="bottom-line"></div></div><script id="hbeData" type="hbeData" data-hmacdigest="{{hbeHmacDigest}}">{{hbeEncryptedData}}</script></div>
wrong_pass_message: Incorrect password, please try again.
wrong_hash_message: Bug found!
Debug
提示“warning: LF will be replaced by CRLF”
啥也别干,它帮你修复了,是安全的。
部署 时 ERROR Deployer not found: git
1 | npm install hexo-deployer-git --save |
css
背景透明
新建 transpancy.css,輸入
1 | /* 文章页背景 */ |
在_config.butterfly.yml 中的 inject: head: 中添加 - <link rel="stylesheet" href="/css/transpancy.css">,並置 footer_bg 爲 false(原爲 transparent)
B 站站外 (外链) 播放器
QueryString 参数:boolean 类型,在 QueryString 中可以使用 0 和 1 表示。
| 参数名 | 类型 | 必要 | 说明 |
|---|---|---|---|
| aid | number | UGC 视频 ID。aid、bvid 选择其一即可 | |
| cid | number | UGC 视频 ID | |
| bvid | string | ✅ | UGC 视频 ID。aid、bvid 选择其一即可 |
| seasonId | number | OGV 视频 ID | |
| episodeId | number | ✅ | OGV 视频 ID。优先级高于 aid、bvid |
| poster | boolean | 展示封面 | |
| autoplay | boolean | 自动播放 | |
| muted | boolean | 静音 | |
| t | number | 跳转到媒体的初始时间点,单位:秒 | |
| danmaku | boolean | false 表示 关闭弹幕,其他表示默认值 | |
| kind | number | 群组种类。非通用业务需要此参数 | |
| refer | boolean | 跳链时携带当前的 Referrer。用于合作方查询来自嵌入网站的跳转次数 | |
| p | number | 多 P 视频的集数。从 1 开始计数,若有 cid 参数,则此参数不生效 |


