HubSpot HubL Code Snippet Collection – Filters, Functions, and Macros


HubSpot HubL Code Snippet Collection – Filters, Functions, and Macros

Below is a list of my commonly used HubSpot CMS HubL filters, functions, and Macros. Email me if you have one you would like to add to this list.

Create a slug from a text string

I used this when I wanted to add a CSS class name to the li of a menu using the text label. This allowed me to target that unique li to style it different from the others.

{% set mystring = "THIS iS jusT a teXt stRing" %}
{{ mystring|lower|replace(' ','-') }}
// this-is-just-a-text-string

Bulk replace a dev domain with a production domain on site launch

I recently worked on a HubSpot site migration and had a lot of links pointing to the development domain. A quick way to update these links is to use this HubL filter |replace(“”,””)

{{ href|replace("devdomain.com", "proddomain.com") }}

 


Written by: Jake Lett
Jake Lett is a results-driven B2B marketing consultant with 15+ years of experience helping businesses boost online visibility, generate qualified leads, and increase sales. Specializing in SEO, HubSpot, and PPC campaign management, Jake leverages proven strategies to deliver measurable growth. As a Certified Google Ads Specialist and HubSpot Developer, he is committed to driving impactful results for his clients.

Related posts

Tags: ,

Want to Get Email Updates of New Articles?

Join My Email Newsletter