Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Targeting a specific page or template with "if" statement

Started by Muut Archive 10 years ago · 2 replies · 724 views
10 years ago

I'm trying to target different page templates or page types to do a few different things. I guess I'm not writing my twig code properly, though. One template is the main blog page (that shows the summary of posts). I've tried several different ways of writing it, usually it just applies the if statement to every page on the site regardless of template.

TXT

10 years ago

Not sure about the '' but I guess you can try

TWIG
{% if page.template == 'blog' %} do the things {% endif %}
👍 1
10 years ago

I tried every combination I could think of but left off the ' ' part. That did the trick! Thank you!!!

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1370 9 years ago
Archive · by Muut Archive, 9 years ago
2 943 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1127 9 years ago