热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

为什么在Jekyll中没有输出site.categories数组?-Whyisthesite.categoriesarraynotbeingoutputinJekyll?

Imbuildingpages(notposts)inJekyll.Onepagedefines2categoriesinthefront-matterasfollo

I'm building pages (not posts) in Jekyll. One page defines 2 categories in the front-matter as follows:

我在Jekyll建立页面(而不是帖子)。一页在前面的内容中定义了两个类别,如下所示:

categories: [document, new]

And then in a layout I'm trying to output the categories object/array, but nothing is being output:

然后在布局中我试图输出类别对象/数组,但没有输出:

Array: {{ site.categories }}

Why wouldn't this output an array as expected?

为什么这不会按预期输出数组?

1 个解决方案

#1


Only post's categories are used to populate site.categories array.

只有帖子的类别用于填充site.categories数组。

In a page, the only way to access categories, from the front matter, is {% for category in page.categories %}. And to scope is restricted to the page itself. :-(

在页面中,从前面的内容访问类别的唯一方法是{%for page.categories%}。并且范围仅限于页面本身。 :-(


推荐阅读
author-avatar
陈小超Sum
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有