Using the Ghost Handlebars Match Helper
Today I was looking for a way to check if a post has a specific primary tag inside a loop, and I found the @Ghost match helper.
In this example, the match helper will check if the primary tag slug is “work”.
{{#match primary_tag.slug "work"}}
{{/match}}
Another use case with custom settings.
Here, match checks whether homepage_layout_style is “Default”.
{{#match @custom.homepage_layout_style "Default"}}
{{/match}}
The homepage_layout_style is a custom setting with the select type.
"homepage_layout_style": {
"type": "select",
"options": [
"Default",
"Image Right",
"Image Circle",
"Image Center",
"Image Wide",
"Image Full"],
"default": "Default",
"group": "homepage"
}
Hopefully, you find this helpful.
More from the Blog
Latest Ghost Themes
Arish
For visual magazines that lead with photography, film, and selected stories.
Siwa
A personal publication that introduces the writer before inviting readers into the stories.
Hanoi
An image-led magazine for creative stories, rich navigation, and long-form reading.
Taba
A newsroom front page for coverage across topics, video, and story formats.
Marsa
A flexible publication homepage for featured stories, topics, and newsletters.
Hakone
For writers who want readers to browse complete posts on the homepage.