Jekyll 中的类别和标签有什么区别?
它们的元素都可以通过for..in
来访问,并且添加类别和标签的方式是相同的。那么,Jekyll 中的类别和标签有什么区别呢?
Both of their elements can be accessed by for..in
, and the way of adding categories and tags are the same. So, what's the difference between categories and tags in Jekyll?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在我看来,唯一重要的区别是类别可以在帖子 url 中使用 - 默认情况下,“啤酒”和“食品”类别内的帖子将具有以下网址:
而不是这个:
查看帖子测试以了解详细信息
标签对网址没有影响,至少根据给他们测试。
It seems to me that the only important difference is that categories can be used in the post url - a post inside the "beer" and "food" categories, by default, will have this url:
Instead of this one:
See the post tests for details
Tags have no influence in the urls, at least according to their tests.
来自文档:
不要将帖子放在文件夹中,您可以指定帖子所属的一个或多个类别。当网站生成时,帖子将表现得就像正常设置了这些类别一样。类别(复数键)可以指定为 YAML 列表或空格分隔的字符串。
与类别类似,可以向帖子添加一个或多个标签。与类别一样,标签可以指定为 YAML 列表或空格分隔的字符串。
这仅仅表明了相似之处;它并没有真正解释类别和标签之间的差异。 此视频教程建议:
它继续解释说
它们本质上
对此类事情的支持将在您正在使用的主题中实现,或者您可以自己实现。
From the documentation:
Instead of placing posts inside of folders, you can specify one or more categories that the post belongs to. When the site is generated the post will act as though it had been set with these categories normally. Categories (plural key) can be specified as a YAML list or a space-separated string.
Similar to categories, one or multiple tags can be added to a post. Also like categories, tags can be specified as a YAML list or a space-separated string.
That only suggests similarities; it doesn't really explain the differences between categories and tags. This video tutorial suggests that:
It goes on to explain that
and that
Support for that kind of thing would be implemented in the theme you're using or you could do it yourself.
v4.2 文档有更新的答案。
类别和标签均可用于 Liquid 模板,并且可以迭代。
类别和标签都可以在帖子的前言中定义。类别也可以通过帖子的文件路径来定义:
The v4.2 documentation has an updated answer.
Both categories and tags are made available to Liquid templates and can be iterated over.
Both categories and tags can be defined in a post's front matter. Categories can also be defined by a post’s file path: