---
title: "HubSpot Theme Development: Clean HubL Best Practices (2026)"
description: "How HubSpot theme development works: theme file structure, CLI setup, theme settings as CSS variables, and the HubL habits that keep a theme clean as it grows."
image: https://www.studionope.com/hubfs/philip-oroni-XV2kGdTo9II-unsplash.jpg
---

[Studio Nope](https://www.studionope.com/)

[Services](https://www.studionope.com/services) [Themes](https://www.studionope.com/themes) [Modules](https://www.studionope.com/modules) [Bundles](https://www.studionope.com/bundles) [Tools](https://www.studionope.com/tools) [Blog](https://www.studionope.com/blog) [Contact](https://www.studionope.com/contact)

hubl

# HUBL and HubSpot CMS Development Without the Spaghetti

Dec 28, 2025 · StudioNope

HubSpot theme development means building a theme: a folder of templates, modules, CSS, JavaScript and a `fields.json` that becomes the theme settings marketers edit, written in HTML and HubL (HubSpot's templating language) and uploaded with the HubSpot CLI. The quickest start is `hs create website-theme`, which copies HubSpot's boilerplate, then `hs watch` to sync your edits. The hard part is not getting a theme to work; it is keeping it clean as it grows, which is what the rest of this guide covers.

HubL is deceptively simple. The syntax is clean, the documentation is available, and you can ship your first template in an afternoon. But three months later, your codebase is a mess. Templates are 800 lines long with inline styles. Modules repeat the same logic because there is no shared utility structure. CSS is scattered across template-level stylesheets with no design token system. Every new page is a copy-paste from the last one, and every copy introduces another slight variation that makes the whole site harder to maintain.

These HubL development best practices are the patterns that separate professional HubSpot CMS development from quick-and-dirty template work. They are the rules we build our own Marketplace themes by.

## What a HubSpot Theme Is Made Of

Every theme has the same shape. This is the layout of one of our Marketplace themes, trimmed to the parts that matter:

```
my-theme/
  theme.json          label, preview page, version, documentation URL
  fields.json         theme settings: colors, fonts, buttons, spacing
  templates/
    layouts/          base.html: the shared <head>, header and footer
    website-pages/    one file per page template
    landing-pages/
    blog/             blog post and blog listing templates
    system/           404, search results, subscription pages
    partials/         header, footer, theme styles
  modules/
    Pricing Cards.module/
      module.html     markup and HubL
      fields.json     the fields editors see
      meta.json       label, icon, content types, JS and CSS options
      module.css
      module.js
  css/
  js/
  images/
```

Each template starts with an annotation comment that tells HubSpot what it is, for example `templateType: page`, a `label`, and `isAvailableForNewContent: true`. Theme settings from `fields.json` are read anywhere in the theme as `{{ theme.group.field }}`, including inside CSS files.

## Set Up Local Development

1. Install Node.js (HubSpot supports version 20 or higher), then the CLI: `npm install -g @hubspot/cli`.
2. Connect your account with `hs account auth`. It walks you through creating a personal access key. Use a free developer test account or a sandbox, not the live portal.
3. Create a theme from HubSpot's boilerplate: `hs create website-theme my-theme`.
4. Upload it once with `hs upload my-theme my-theme`, then run `hs watch my-theme my-theme` so every save uploads automatically.
5. Keep the theme folder in git. Design Manager has version history per file, but git is what lets you review a change across thirty files before it reaches a live site.

If you are changing an existing Marketplace theme rather than building one, make a child theme in Design Manager instead. It inherits the parent and holds only the files you override, so the parent keeps receiving its updates.

## Structure Templates Around Reusable Modules, Not Page-Level Code

The most common HubL mistake is building page-specific templates with all the HTML, CSS, and logic inline. Every template becomes a monolith. Instead, push every [repeatable UI pattern into a module](https://www.studionope.com/blog/how-to-build-a-custom-module-in-hubspot-cms). The template should be a thin shell that defines the page structure and drops in modules. When a module needs updating, you change it once and every page that uses it updates automatically.

## Use Design Tokens Through CSS Custom Properties

Define your colors, spacing, typography, and border radius values as CSS custom properties in a single file. Reference those variables throughout your modules. When a client wants to change their brand color, you change one variable instead of searching through 30 files. This is how themes like the [Studio Nope Theme](https://studionope.com/nope-theme) maintain visual consistency across 47 modules and 44 page templates.

The bridge between the two is a small partial that writes theme settings into those variables, once, for the whole site:

```
:root {
  --color-primary: {{ theme.colors.primary.color }};
  --font-heading: {{ theme.typography.heading_font.font }};
  --radius: {{ theme.style.corner_radius }}px;
}
```

Modules then use `var(--color-primary)` and never read the theme setting directly. Rename a setting later and you fix one file, not forty.

## Keep Module Fields Flat and Predictable

Deeply nested field groups make modules harder to maintain and harder for content editors to use. Keep your field structure as flat as possible. Group fields logically (Content, Style, Settings) but avoid nesting more than two levels deep. Every additional level of nesting is friction for your future self and for the marketing team using the module.

## Avoid Inline Styles in Templates

Inline styles bypass the cascade, make responsive behavior harder to implement, and create maintenance nightmares. Use class-based styling with CSS custom properties. The only exception is dynamic values from module fields (like user-selected colors), which should be applied as CSS custom properties on the module wrapper, not as inline styles on individual elements.

## Performance Matters More Than You Think

HubSpot CMS development tips that often get ignored: avoid loading jQuery when vanilla JavaScript handles the same interactions. Minimize render-blocking resources. Use `defer` on scripts that do not need to execute before the DOM is ready. Lazy-load images below the fold. Every millisecond of load time affects Core Web Vitals, which affects search rankings, which affects the traffic your client's marketing team is working hard to earn.

## Write Clean HubL Code That Other Developers Can Read

Use consistent indentation. Name variables descriptively. Comment complex logic. [Format your HubL tags consistently](https://www.studionope.com/blog/how-to-keep-hubl-readable-as-your-hubspot-site-grows). If your codebase will be maintained by someone other than you (and it will), readability is not optional. Tools like the [HubL Code Formatter](https://studionope.com/hubl-code-formatter) browser extension can enforce consistent formatting automatically.

## Test Across Design Contexts

A module that looks perfect on a white background may break on a dark background. A layout that works with 3 items may collapse with 1 or overflow with 10. Test your modules with minimum, maximum, and empty content states. Test with both light and dark theme settings. Test on mobile. Most HubL bugs are not code errors. They are untested edge cases.

## Questions People Ask About HubSpot Theme Development

### What is HubL?

HubL is HubSpot's templating language, based on Jinja. It adds variables, loops, conditionals, filters and functions to HTML, and it is what templates and modules use to print module fields, theme settings and CMS content. It runs on HubSpot's servers when the page renders, so visitors only ever receive the finished HTML.

### Do I need to know React to build a HubSpot theme?

No. HubL themes with HTML, CSS and JavaScript remain the standard, and almost every Marketplace theme is built that way. HubSpot also supports React-based modules (its default Elevate theme uses them), which are worth learning if you want to build interactive modules in React, but they are optional.

### Should I start from the HubSpot boilerplate or from scratch?

Start from the boilerplate (`hs create website-theme`) if this is your first theme. It gives you the folder structure, a working base layout and the system templates, which are easy to forget. Once you have built a few themes you will have your own starting point, which is what most studios end up using.

### Can I edit a theme I bought on the HubSpot Marketplace?

Not directly. Marketplace themes install read-only. Change styling through the theme settings, and for code changes create a child theme or a clone in Design Manager. The trade-offs are covered in [how to change your HubSpot theme](https://www.studionope.com/blog/how-to-change-your-hubspot-theme).

### How do I test a theme before it goes live?

Build and upload to a developer test account or sandbox, preview it with the theme previewer, and test every module with empty, minimum and maximum content on desktop and mobile. Then run the pages through PageSpeed Insights before anyone builds real content on them.

## Level Up Your HubSpot CMS Development

[Clean HubL code](https://www.studionope.com/services/hubl-hubspot-cms-development), modular architecture, design tokens, and performance optimization are not extras. They are the baseline for professional HubSpot development. Browse [HubSpot themes](https://studionope.com/themes) to see these patterns in production, or check out the [developer tools](https://studionope.com/tools) that make the workflow faster.

[hubl](https://www.studionope.com/blog/tag/hubl)[hubspot code](https://www.studionope.com/blog/tag/hubspot-code)[hubspot cms development](https://www.studionope.com/blog/tag/hubspot-cms-development)[Tutorials](https://www.studionope.com/blog/tag/tutorials)

Related reading

- [HubL and HubSpot CMS development→](https://www.studionope.com/services/hubl-hubspot-cms-development)
- [How to Keep HubL Readable as Your HubSpot Site Grows→](https://www.studionope.com/blog/how-to-keep-hubl-readable-as-your-hubspot-site-grows)
- [How to Build a Custom Module in HubSpot CMS (2026 Guide)→](https://www.studionope.com/blog/how-to-build-a-custom-module-in-hubspot-cms)
- [How to Add llms.txt to Your HubSpot Website→](https://www.studionope.com/blog/how-to-add-llms-txt-to-your-hubspot-website)

## Get the writingin your inbox.

New posts on HubSpot themes, modules, and CMS development. No spam, unsubscribe anytime.

## Tell us whatyou're building.

Themes, modules, full builds, audits, migrations. Send the shape of it and we'll come back with a clear scope and a price.

[Get in touch →](https://www.studionope.com/contact)

[Studio Nope](https://www.studionope.com/)

© 2026 Studio Nope.  
All rights reserved.

##### Products

[Themes](https://www.studionope.com/themes)[Modules](https://www.studionope.com/modules)[Bundles](https://www.studionope.com/bundles)[Tools](https://www.studionope.com/tools)

##### Services

[Custom themes](https://www.studionope.com/services/custom-hubspot-theme-development)[Branding & design](https://www.studionope.com/services/hubspot-branding-design)[HubL & CMS dev](https://www.studionope.com/services/hubl-hubspot-cms-development)[Website builds](https://www.studionope.com/services/hubspot-website-funnel-builds)[Audits & migrations](https://www.studionope.com/services/hubspot-audits-fixes-migrations)

##### Company

[Blog](https://www.studionope.com/blog)[FAQ](https://www.studionope.com/faq)[Contact](https://www.studionope.com/contact)[Legal](https://www.studionope.com/legal)

##### Get in touch

[hello@studionope.com](mailto:hello@studionope.com)[Contact](https://www.studionope.com/contact)[YouTube](https://www.youtube.com/@Hello-Studio-Nope)[Framer](https://www.framer.com/@studionope/)

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "StudioNope",
    "url" : "https://www.studionope.com/blog/author/studionope"
  },
  "dateModified" : "2026-01-03T19:40:27.850Z",
  "datePublished" : "2025-12-28T12:46:28.000Z",
  "headline" : "HubSpot Theme Development: Clean HubL Best Practices (2026)",
  "image" : [ "https://www.studionope.com/hubfs/philip-oroni-XV2kGdTo9II-unsplash.jpg" ],
  "mainEntityOfPage" : {
    "@id" : "https://www.studionope.com/blog/hubl-and-hubspot-cms-development-without-the-spaghetti",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://www.studionope.com/hubfs/studio-nope-logo.png"
    }
  }
}
```

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "StudioNope"
  },
  "dateModified" : "2026-11-23T15:42:43Z",
  "datePublished" : "2025-12-28T12:46:28Z",
  "headline" : "HUBL and HubSpot CMS Development Without the Spaghetti",
  "image" : "https://146897094.fs1.hubspotusercontent-eu1.net/hubfs/146897094/philip-oroni-XV2kGdTo9II-unsplash.jpg",
  "mainEntityOfPage" : {
    "@id" : "https://www.studionope.com/blog/hubl-and-hubspot-cms-development-without-the-spaghetti",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@id" : "https://www.studionope.com/#studio",
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://www.studionope.com/hubfs/studio-nope-logo-smoke-black.svg"
    },
    "name" : "Studio Nope"
  },
  "url" : "https://www.studionope.com/blog/hubl-and-hubspot-cms-development-without-the-spaghetti"
}
```