为 Jekyll 设置默认值 collections
Setting defaults for Jekyll collections
出于某种原因,我无法为我的 Jekyll collection 设置默认值。我 认为 我正确地遵循了 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"
我的博客 post markdown 文件在 /_posts
中,我的作品 (collection) markdown 文件在 /_work
中。在上面的示例中,我希望所有工作项都使用 work
collection。这怎么行不通?
顺便说一下,我使用的是 Jekyll 3.3.1。
您指的是具有路径 '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"
出于某种原因,我无法为我的 Jekyll collection 设置默认值。我 认为 我正确地遵循了 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"
我的博客 post markdown 文件在 /_posts
中,我的作品 (collection) markdown 文件在 /_work
中。在上面的示例中,我希望所有工作项都使用 work
collection。这怎么行不通?
顺便说一下,我使用的是 Jekyll 3.3.1。
您指的是具有路径 '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"