HubSpot Custom Module Boilerplate Code Snippet


HubSpot Custom Module Boilerplate Code Snippet

Below is a some boilerplate code to use when creating a custom module inside HubSpot CMS.

{# 
HubSpot uses different prefixes so this just gets the number    
module_#########
widget_#########
outputs just the number
#}
{% set instanceID = name[7:] %}
{{ instanceID }}

<div class="module-class" id="module{{instanceID}}">
    <div class="row-fluid">
        <div class="span6">A</div>  
        <div class="span6">B</div> 
    </div>  
</div>

{% require_head %}
<# optional - if you need to add something to the HEAD #>
{% end_require_head %}

{% require_css %}
<style>
{% scope_css %}
{% end_scope_css %}

</style>
{% end_require_css %}


{% require_js %}
<script>
document.addEventListener("DOMContentLoaded", function () {
    const moduleWrapper = document.querySelector("#module{{ instanceID }}");
});

window.addEventListener("load", (event) => {

});
</script>
{% end_require_js %}

About the Author

Jake Lett is a results-driven Detroit based B2B marketing consultant with 15+ years of hands-on experience managing SEO and PPC campaigns across manufacturing, SaaS, and professional services industries. He’s a Certified Google Ads Specialist and HubSpot CMS Developer who has personally managed budgets ranging from $500 to over $10,000/month.

Jake specializes in helping small businesses and solo marketers get more from lean ad budgets—using practical strategies that drive qualified leads, not just traffic. He shares real-world lessons on his blog, YouTube channel, and in his published books on digital marketing.



Related posts

Tags: ,

Want to Get Email Updates of New Articles?

Join My Email Newsletter