我的_data目录中有一个YAML文件。我已经通过YMLLint运行了它,并且一切正常。该文件如下所示:
{ }
在我的包含文件中,我可以打印出整个文件
- sbSecId: 0
title: Getting Started
link:
isLastSubSectionItem: 0
- sbSecId: 0
title: Developer Quick Start
link:
isLastSubSectionItem: 0
- sbSecId: 0
title: Examples
link:
isLastSubSectionItem: 1
- sbSecId: 0
title: Troubleshooting
link:
isLastSubSectionItem: 0
- sbSecId: 0
title: Dev Tips
link:
isLastSubSectionItem: 0
- sbSecId: 0
title: Common Issues
link:
isLastSubSectionItem: 0
...
并将其显示在页面上:
{{site.data.sidebar}}
我可以循环运行
{"sbSecId"=>0, "title"=>"Getting Started", "link"=>nil, "isLastSubSectionItem"=>0}{"sbSecId"=>0, "title"=>"Developer Quick Start", "link"=>nil, "isLastSubSectionItem"=>0}{"sbSecId"=>0, "title"=>"Examples", "link"=>nil, "isLastSubSectionItem"=>1}
,我将在页面上看到一列规则。到目前为止,一切都很好。但是我无法访问任何实际数据。如果将其放入循环中:
{% for item in site.data.sidebar %}
<hr>
{% endfor %}
什么都没有出现。难道我做错了什么?