首页 文章

设置Jekyll集合的默认值

提问于
浏览
3

出于某种原因,我无法为我的Jekyll集合设置默认值 . 我想我已经正确地遵循了documentation,但即使设置默认 layout 也暗指我...

这是我得到的:

collections:
  work:
    output: true
    permalink: /work/:path/

defaults:
  -
    scope:
      path: ""
      type: "posts"
    values:
      layout: "post"
  -
    scope:
      path: "work"
      type: "pages"
    values:
      layout: "work"

我的博客发布降价文件位于 /_posts ,我的工作(收藏)降价文件位于 /_work . 在上面的示例中,我希望所有工作项都使用 work 集合 . 这怎么不行?

顺便说一句,我使用的是Jekyll 3.3.1 .

1 回答

  • 7

    您指的是具有路径“work”的页面,而您想要引用集合“work”中的所有项目 . 这可以通过仅指定'type'(集合)并将路径留空来完成,如下所示:

    collections:
      work:
        output: true
        permalink: /work/:path/
    
    defaults:
      - scope:
          path: ""
          type: "posts"
        values:
          layout: "post"
      - scope:
          path: ""
          type: "work"
        values:
          layout: "work"
    

相关问题