Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Targeting a specific page or template with "if" statement

Started by Muut Archive 10 years ago · 2 replies · 803 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 2299 9 years ago
Archive · by Muut Archive, 9 years ago
2 1509 9 years ago
Archive · by Muut Archive, 9 years ago
2 4765 9 years ago
Archive · by Muut Archive, 9 years ago
1 3581 9 years ago
Archive · by Muut Archive, 9 years ago
3 1635 9 years ago