You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Jekyll中为Front-matter默认配置添加例外规则?

解决Jekyll默认Front-matter豁免索引文件的问题

你可以通过在defaults的scope中添加exclude字段,指定排除目录下的索引文件(比如index.md或index.html),避免索引文件被设为自身的子项。修改后的配置如下:

defaults:
  - scope:
      path: "./Articles"
      exclude: "index.md" # 排除该目录下的索引文件
    values:
      parent: Articles
      nav_exclude: true
  - scope:
      path: "./Books"
      exclude: "index.md"
    values:
      parent: Books
      nav_exclude: true

如果你的索引文件后缀是.html,把exclude的值改成index.html即可。

另外,也可以用path: "./Articles/*"这种精确路径匹配,限定规则仅作用于目录下的子文件而非索引文件,但这种方式会忽略目录下的子目录文件,因此优先推荐exclude的方式,更灵活且不会遗漏子目录内容。

内容的提问来源于stack exchange,提问作者Ghassan Shahzad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.26 00:27:08