Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

If a Taxonomy Exists

Solved by Paul Hibbitts View solution

Started by Claud Rusnac 9 years ago · 1 replies · 685 views
9 years ago

I am trying to write some code to determine if a Taxonomy is set on a particular page, but I must be doing something wrong...

TWIG
{% if page.taxonomy.type == "general" %}
            Do Something... 
{% endif %}

Page Header

YAML
---
title: Page Title
taxonomy:
    category: ['docs']
    role:
    type: ['general']
    execution:
modified_date: 10/12/2017
---
9 years ago Solution

Hi @crusnac, this is untested but perhaps this?

TWIG
{% if "general" in page.taxonomy['type'] %} 

Let me know if that actually works🙂

👍 1

Suggested topics

Topic Participants Replies Views Activity
Support · by complanar, 6 days ago
6 140 16 hours ago
Support · by Rick Beebe, 6 days ago
2 100 2 days ago
Support · by blu3prince, 3 days ago
0 52 3 days ago
Support · by alex, 4 days ago
2 92 3 days ago
Support · by Marcel, 2 weeks ago
1 143 4 days ago