YML 内容未在 Jekyll 中显示 collections
YML content not displaying in Jekyll collections
我正在尝试显示 collection 小说中的项目。网站上只显示 url。
collection 的 for 循环在这里
{% for fiction_item in site.fiction %}
<ul class="col-xl-3 col-lg-4 col-md-6 mb-4">
<li class="bg-white"><img class="img-fluid card-img-top" src="{{ fiction_item.image_url }}" alt="{{ fiction_item.title }}">
<div class="p-4 art-content">
<h5>{{ fiction_item.title }}</h5>
<h6>by {{ fiction_item.writer }}</h6>
<p class="small text mb-0">{{ fiction_item.caption }}</p><a class="btn border-pretty" href="{{ site.url }}{{ fiction_item.url }}">More</a>
</div>
</li>
</ul>
{% endfor %}
我的_config.yml是这样写的
name: The Book Project
url: '/experiment/'
baseurl: '/experiment/'
collections:
nonfiction:
output: true
fiction:
output: true
art:
output: true
poetry:
output: true
defaults:
- scope:
path: ""
type: "nonfiction"
values:
layout: "blog"
- scope:
path: ""
type: "fiction"
values:
layout: "blog"
- scope:
path: ""
type: "art"
values:
layout: "blog"
- scope:
path: ""
type: "poetry"
values:
layout: "blog"
markdown内容是这样的:
---
layout: blog
title: History of India
image_url: https://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Cave_26%2C_Ajanta.jpg/348px-Cave_26%2C_Ajanta.jpg
writer: Adnan Abbasi
caption: Whendefining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. You can optionally specify a directory to store all your collections in the same place with collections_dir: my_collections. Then Jekyll will look in my_collections/_books for the books collection, and in my ...
---
When defining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. You When defining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. YouWhendefining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. You
When defining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. You When defining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. YouWhendefining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. You
同样的问题发生在个别 collection 页面上:
项目的 link 在这里:http://thebookproject.team/experiment/fiction.html
其 github 的 link 在这里:https://github.com/thebookproject/experiment
我到底哪里错了?
问题出在降价文件的前面。
当我尝试在本地构建网站时,我收到一条错误消息,提示前文解析失败:
caption: blah blah collections_dir: my_collections.
这一行有多个变量声明,caption:
和collections_dir:
。要解决此问题,请尝试将您的标题用引号引起来,如下所示:
caption: "blah blah collections_dir: my_collections."
这为我修复了构建错误。
我正在尝试显示 collection 小说中的项目。网站上只显示 url。
collection 的 for 循环在这里
{% for fiction_item in site.fiction %}
<ul class="col-xl-3 col-lg-4 col-md-6 mb-4">
<li class="bg-white"><img class="img-fluid card-img-top" src="{{ fiction_item.image_url }}" alt="{{ fiction_item.title }}">
<div class="p-4 art-content">
<h5>{{ fiction_item.title }}</h5>
<h6>by {{ fiction_item.writer }}</h6>
<p class="small text mb-0">{{ fiction_item.caption }}</p><a class="btn border-pretty" href="{{ site.url }}{{ fiction_item.url }}">More</a>
</div>
</li>
</ul>
{% endfor %}
我的_config.yml是这样写的
name: The Book Project
url: '/experiment/'
baseurl: '/experiment/'
collections:
nonfiction:
output: true
fiction:
output: true
art:
output: true
poetry:
output: true
defaults:
- scope:
path: ""
type: "nonfiction"
values:
layout: "blog"
- scope:
path: ""
type: "fiction"
values:
layout: "blog"
- scope:
path: ""
type: "art"
values:
layout: "blog"
- scope:
path: ""
type: "poetry"
values:
layout: "blog"
markdown内容是这样的:
---
layout: blog
title: History of India
image_url: https://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Cave_26%2C_Ajanta.jpg/348px-Cave_26%2C_Ajanta.jpg
writer: Adnan Abbasi
caption: Whendefining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. You can optionally specify a directory to store all your collections in the same place with collections_dir: my_collections. Then Jekyll will look in my_collections/_books for the books collection, and in my ...
---
When defining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. You When defining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. YouWhendefining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. You
When defining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. You When defining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. YouWhendefining a collection as a sequence, its pages will not be rendered by default. To enable this, output: true must be specified on the collection, which requires defining the collection as a mapping. For more information, see the section Output. Gather your collections 3.7.0. You
同样的问题发生在个别 collection 页面上:
其 github 的 link 在这里:https://github.com/thebookproject/experiment
我到底哪里错了?
问题出在降价文件的前面。
当我尝试在本地构建网站时,我收到一条错误消息,提示前文解析失败:
caption: blah blah collections_dir: my_collections.
这一行有多个变量声明,caption:
和collections_dir:
。要解决此问题,请尝试将您的标题用引号引起来,如下所示:
caption: "blah blah collections_dir: my_collections."
这为我修复了构建错误。