Using the Ghost Handlebars Match Helper

Ahmad Ajmi Photo
Ahmad Ajmi

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.

In this example, the match helper will check if the homepage_layout_style setting 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.


Subscribe to Aspire Themes

You will receive Ghost resources, new themes, and updates.


Write more
Save time & money

Ghost CMS themes for a professional-looking website. Newsletter & membership full support.

Choose your theme →
  • Ghost 4 Support
  • Free Support & Updates
  • 100% Money Back Guarantee