Creating Custom Sections
Custom sections are reusable page building blocks in HubSpot’s drag-and-drop editor. FreshJuice DEV provides several built-in sections that you can use as templates for creating your own.Section Anatomy
A section in FreshJuice DEV consists of a single HTML file located intheme/sections/ with special metadata and HubL markup.
Basic Structure
Section Examples
Simple Hero Banner
The hero banner section (theme/sections/hero-banner.html:1) demonstrates a two-column layout:
- Uses
contextvariables for flexible content - 12-column grid system (width=6 means 50%)
- Default values with
oroperator
Multi-Column Section
The multi-column section (theme/sections/multi-column-content.html:1) shows a three-column layout:
- Three equal columns (width=4 each)
- Offset positioning for precise control
- Lazy loading images for performance
Call-to-Action Section
The CTA section (theme/sections/call-to-action.html:1) demonstrates background images and responsive padding:
- Background image configuration
- Responsive padding for mobile/desktop
- Max-width constraint for content
Creating Your Own Section
Step 1: Create the File
Create a new file intheme/sections/ with a descriptive name:
Step 2: Add Metadata
Start with the HTML comment block:Step 3: Build the Layout
Use HubSpot’s drag-and-drop tags:Step 4: Add Context Variables
Make your section flexible with context variables:Step 5: Use Custom Modules
Reference custom modules in your sections:Grid System
FreshJuice DEV uses HubSpot’s 12-column grid system:- Full width:
width=12 - Half width:
width=6 - Third width:
width=4 - Quarter width:
width=3
Column Offset
Useoffset to position columns:
Best Practices
1. Use Context Variables
Always provide default values:2. Optimize Image Loading
Use lazy loading for below-the-fold images:3. Make It Responsive
Provide mobile and desktop configurations:4. Add Preview Screenshots
Create a preview image attheme/images/section-previews/ for better UX in the page editor.
5. Semantic HTML
Use appropriate HTML elements through modules:Working with Custom Modules
Sections often use custom modules. Reference them using relative paths:theme/sections/cards.html:1) for a complete example using the custom card module.
Testing Your Section
-
Upload to HubSpot:
- Open any page in the drag-and-drop editor
- Look for your section in the section selector
- Drag it onto the page to test
Advanced Techniques
Dynamic Grid Classes
The card module demonstrates conditional grid classes:Looping Through Content
Create repeatable content blocks:Conditional Rendering
Show/hide elements based on content:Common Section Patterns
Hero Section Pattern
- Full-width background
- Centered content
- CTA button
- Hero image
Feature Section Pattern
- Multiple columns
- Icon or image per feature
- Heading and description
- Optional link/button
CTA Section Pattern
- Background image or color
- Centered heading
- Prominent button
- Minimal content
Content Section Pattern
- Text and image combination
- Alternating layouts
- Flexible column widths
Next Steps
- Learn about creating custom modules
- Explore performance optimization
- Review HubSpot’s drag-and-drop documentation
Resources
- Example sections:
theme/sections/ - Section previews:
theme/images/section-previews/ - HubSpot modules: Official Documentation