前言

对于一些全局的改变,我们可以用文件来管理更方便。

(20250621更新:网上很多帖子是在source/_data文件夹下创建的,都可以)

步骤

  1. \themes\butterfly\source\css 目录下添加 custom.css 文件
  2. \themes\butterfly\source\js 目录下添加 custom.js 文件
  3. 在内层 _config.yml 文件中搜索 inject 或者直接在外层 _config.butterfly.yml 文件中添加如下代码即可:
# Inject
# Insert the code to head (before '</head>' tag) and the bottom (before '</body>' tag)
inject:
head:
- <link rel="stylesheet" href="/css/custom.css">
bottom:
- <script src="/js/custom.js"></script>

之后,对于一些全局的修改都可以在 custom.csscustom.js 中编辑,这样管理和更新的时候方便些。