Only showing updated_at if it is different from published_at

Is there a way within the HBS files to only show the updated_at value if it differs from published_at?

I currently use something like this.

Published: <time datetime="{{date format="YYYY-MM-DD"}}">{{date published_at}}</time>
{{#if updated_at}}
Updated: <time datetime="{{date format="YYYY-MM-DD"}}">{{date updated_at}}</time>

It always displays the updated date, since updated_at seems to always contain a value (the published_at value), even if the post was never actually edited/updated.

Is there a way to use if statements or something within handlebars so that it only renders the updated_at time if it’s actually been updated (or different from the published date if it must have a value)? I found this CSS alternative but that’s it…


You can try the {{match}} helper. It’s not yet documented, but here’s an example:

{{#match updated_at "!=" published_at}}

Thanks, that works perfectly. :+1: