Check if blog post comments are enabled on HubSpot using HubL

    Difficulty Level: Intermediate. This post assumes a solid understanding of HubSpot tools and some technical knowledge. Instructions are detailed and can be applied as they appear on the post.

    Sometimes you may want to use a snippet to check if the blog comments have been enabled to display a particular snippet of code in your HubSpot blog template. 

    I wasn't able to find anything specific in the documentation but have found the following condition to work:

    {% raw %}{% if content_group.allow_comments %}
      {# Your code here #}
    {% endif %}

    You can use this in a coded template, a custom module or in the Wrapping HTML section in a Module group in your blog template, like this: 

    Wrapping HTML - If comments are enabled

    In the above case I found it useful so that the padding from my page-center and content-wrapper classes won't add extra whitespace if comments are disabled.

    I found this by using the Developer Info viewer (see below) - you can use dot notation to find the values of any of the information that appears there.

    HubSpot Tools - Developer Info

    Check out my post on adding custom fields to HubSpot blog posts for ways to create your own fields on posts and similarly access them on there or on the listings page. 

    Written by: Stephanie O'Gay Garcia Orginally Published: December 13, 2019 Last Updated: January 6, 2020

    Thank you! I appreciate the feedback 😊

    Sorry to hear that! 🙁

    I'd appreciate if you could take a moment to let me know how I can improve this article.

    New call-to-action

    Looking for a HubSpot website developer?

    Let me help you with website themes, templates, page setup and custom modules. 

    Get in touch

    Stephanie O'Gay Garcia

    Hi! 👋 I'm a freelance HubSpot Website Developer based in Toronto (Canada). Give me a shout if you have questions about this post or there's anything I can help you with.