1
votes

I have a jekyll post with YAML Front Matter like so:

---
layout: post
title:  "Insulation"
categories: build-manual
variable: build-manual // this is just for troubleshooting purposes
---

You would think on the post's page I could write a simple liquid if / then statement using the current post's category. Something like this:

{% if page.categories == 'build-manual' %}
Hey I am in build-manual category
{% else %}
No I am not in build-manual category
{% endif %}

For some reason, this does not work. I receive the output: "No I am not in build-manual category"

To make it more confusing, if I change "page.categories" to "page.variable" it works. I receive the output: "Hey I am in build-manual category"

Any ideas on why it's not recognizing the categories?

1
Did you try {% if post.categories == 'build-manual' %} ?Virtua Creative
Yes. That didn't work.Zach Both

1 Answers

0
votes

This solved the problem:

{% if page.categories contains "build-manual" %}
{% endif %}