在我的个人网站上,我根据文章的分类在主页上设置文章列表的样式。所以如果我有正题:
---
layout: post
title: "My Post"
date: 2016-01-26
category: code
---由于类别是code,下面的div将呈现为具有css类的card-code,并相应地设置文章摘录的样式。
{% for post in site.posts %}
<div class="col-1-2">
<!-- This Line! -->
<div class="paper-card card-{{ post.category }}">
<!-- other code -->
</div>
</div>
{% endfor %}为了简化我的生活,我在我的general文件中设置了默认的帖子类别为_config.yml:
default:
-
scope:
path: ""
type: "posts"
values:
category: "general"然而,{{ post.category }}没有为这些帖子提供任何内容(即card-)。知道为什么这不管用吗?
发布于 2016-02-03 10:52:03
阅读前部缺省值上的文档,这一节应该称为defaults而不是default。
在你的_config.yaml里试试这个
defaults:
-
scope:
path: ""
type: "posts"
values:
category: "general"https://stackoverflow.com/questions/35143696
复制相似问题