Reputation: 1030
On my personal site, I style the post list on my home page based on the post's category. So if I have the front matter:
---
layout: post
title: "My Post"
date: 2016-01-26
category: code
---
Because the category is code
, the div below will render to have a css class card-code
and style the post excerpt accordingly.
{% for post in site.posts %}
<div class="col-1-2">
<!-- This Line! -->
<div class="paper-card card-{{ post.category }}">
<!-- other code -->
</div>
</div>
{% endfor %}
To try to make my life simpler, I set the default category for posts to be general
in my _config.yml
file:
default:
-
scope:
path: ""
type: "posts"
values:
category: "general"
However, {{ post.category }}
comes up with nothing for these posts (i.e., card-
). Any ideas why this ain't working?
Upvotes: 0
Views: 86
Reputation: 3596
Reading the documentation at Front Matter Defaults the section should be called defaults
not default
.
Try this in your _config.yaml
defaults:
-
scope:
path: ""
type: "posts"
values:
category: "general"
Upvotes: 1