What It Does
The Custom Liquid section provides a code editor within the theme customizer, allowing developers to inject custom Liquid code, include app snippets, or create advanced customizations without editing theme files directly. This is the designated area for technical modifications and custom functionality.Getting Started
Add the Section
Add the Custom Liquid section to any template where you need custom code functionality
Write or Paste Liquid Code
Use the code editor to write Liquid markup, HTML, CSS, or JavaScript wrapped in appropriate tags
Test Thoroughly
Preview your changes carefully before publishing. Invalid Liquid can cause rendering issues
Settings
Custom Liquid
Custom Liquid
Type: Liquid code editor
Default: EmptyA code editor field where you can write or paste custom Liquid code, HTML, CSS, or JavaScript. This field has full access to Liquid objects, filters, and tags available in Shopify themes.Integrate third-party apps by rendering their snippets. Most Shopify apps provide snippet code for integration.Custom Product Grids:Create customized product displays beyond standard section capabilities.Dynamic Content:Show different content based on customer login status, cart contents, or other conditions.Custom Forms:Build custom forms for contact, newsletter, or product customization.Embedded Content:Embed external widgets, calendars, booking systems, or third-party content.Custom CSS/JavaScript:Add page-specific styling or functionality (wrap in appropriate tags).
Default: EmptyA code editor field where you can write or paste custom Liquid code, HTML, CSS, or JavaScript. This field has full access to Liquid objects, filters, and tags available in Shopify themes.
What You Can Add
App Snippets:Code Editor Features
- Syntax highlighting: Liquid, HTML, CSS, and JavaScript syntax coloring
- Line numbers: Easy reference for debugging
- Indentation support: Tab key for proper code formatting
- Error highlighting: Basic syntax error detection (not foolproof)
Important Guidelines
Do:- Test code in a duplicate/staging theme first
- Use comments to document what custom code does
- Follow Liquid best practices and syntax
- Validate HTML to ensure proper structure
- Keep code organized and readable
- Copy-paste code you don’t understand
- Include unescaped customer input (security risk)
- Create very long code blocks (use snippets instead)
- Forget to test on mobile devices
- Override critical theme functionality without backup
Security Considerations
The Custom Liquid section has full theme access, meaning:- Code executes server-side during page render
- Has access to all Liquid objects (customer data, products, orders)
- Can modify page structure and functionality
- Can include external resources
- API keys or passwords in plain text
- Unvalidated customer input that could execute malicious code
- Resource-intensive operations that slow page rendering
- Code from untrusted sources
Performance Tips
- Limit API calls: Liquid executes server-side; excessive API calls slow page rendering
- Cache when possible: Use Liquid variables to avoid repeated calculations
- Minimize external resources: Each external script/style adds load time
- Test load time: Use browser dev tools to ensure custom code doesn’t create bottlenecks
Padding Top
Padding Top
Type: Range slider
Range: 0-100px (increments of 4px)
Default: 40pxVertical spacing (padding) above the custom liquid content. Controls distance from the previous section or page element.
Range: 0-100px (increments of 4px)
Default: 40pxVertical spacing (padding) above the custom liquid content. Controls distance from the previous section or page element.
When to Adjust
Increase (60-100px):- Custom content is visually prominent (needs breathing room)
- Creating hero-like custom sections
- Content needs clear separation from above section
- Custom content is supplementary (subtle addition)
- Multiple custom liquid sections stacked closely
- Tighter, content-dense layouts
- Custom content is continuous with previous section
- Building integrated custom layouts
- Advanced design scenarios with custom spacing
Padding Bottom
Padding Bottom
Type: Range slider
Range: 0-100px (increments of 4px)
Default: 52pxVertical spacing (padding) below the custom liquid content. Controls distance to the next section or page element.
Range: 0-100px (increments of 4px)
Default: 52pxVertical spacing (padding) below the custom liquid content. Controls distance to the next section or page element.
When to Adjust
Increase (60-100px):- Custom content concludes a major page section
- Creating visual breaks between distinct page areas
- Custom content needs clear ending
- Next section is closely related
- Reducing cumulative whitespace on long pages
- Tighter layouts
- Next section is continuous part of custom layout
- Building integrated custom designs
- Advanced spacing control
Padding Coordination
The default values (40px top, 52px bottom) create 92px total vertical spacing around custom content. Adjust both values proportionally to maintain visual balance unless you specifically need asymmetric spacing.Best practices
Test in Duplicate Theme First
Always test custom Liquid in a duplicate/staging theme before implementing in your live theme. Invalid code can break page rendering.
Document Your Code
Add comments explaining what custom code does and why it’s there. Future you (or other developers) will appreciate the context.
Keep Code Organized
For complex customizations, create a snippet file and render it from Custom Liquid section rather than writing 100+ lines inline.
Validate Before Publishing
Use HTML validators and Liquid syntax checkers to catch errors before they reach customers. Preview extensively on desktop and mobile.
Avoid Hardcoded Values
Use Liquid variables and settings rather than hardcoding product IDs, URLs, or text. Makes maintenance easier when things change.
Consider Performance Impact
Monitor page load time after adding custom Liquid. Heavy operations, many API calls, or large external scripts can slow rendering significantly.
Never Expose Sensitive Data
Don’t include API keys, passwords, or sensitive credentials in Custom Liquid. Use secure app integrations or backend logic instead.
Mobile-First Approach
Always test custom code on mobile devices. What works on desktop may have layout or performance issues on mobile connections.
Common Use Cases
App Snippet Integration
Use case: Integrating third-party Shopify apps that provide snippet codeCustom Product Showcase
Use case: Featured products with custom layout beyond standard sectionsPersonalized Welcome Message
Use case: Show different content to logged-in vs guest customersConditional Announcement Banners
Use case: Show banners only to specific customer segments or during specific timesExternal Widget Embedding
Use case: Integrate booking system, event calendar, or external toolCart-Based Conditional Content
Use case: Show different messages based on cart contents or valueTechnical Notes
Liquid Object Access
The Custom Liquid section has full access to Shopify’s Liquid objects based on template context: Available Everywhere:shop- Store informationcart- Current cart contentsrequest- Page request informationsettings- Theme settingstemplate- Current template name
product- Product template onlycollection- Collection template onlyarticle- Article/blog template onlypage- Page template onlycustomer- All templates (null if not logged in)
- Section-specific settings from other sections (isolated scope)
- Data from apps unless they provide Liquid objects
Server-Side vs Client-Side Execution
Server-Side (Liquid):- Executes during page render on Shopify servers
- Has access to all Shopify data (products, customers, orders)
- Output is HTML sent to browser
- Cannot respond to user interactions after page load
- Executes in customer’s browser after page loads
- Can respond to clicks, scrolls, form submissions
- Must use Ajax/fetch to access Shopify data
- Use
<script>tags within Custom Liquid for client-side code
Code Limitations
- No file system access: Cannot create/read files outside Liquid scope
- No database queries: Can only access data through Liquid objects
- No external API calls: Liquid doesn’t support HTTP requests to external services
- Output buffering: Very large output (thousands of lines) may be truncated
Snippet Alternative
For complex or reusable custom code, consider creating a snippet file instead:- Create
snippets/custom-homepage-hero.liquidin theme code editor - Write full code in snippet file (easier editing, version control)
- Use Custom Liquid section to render snippet:
- Easier code editing (full code editor vs. small inline field)
- Reusable across multiple pages
- Better organization
- Easier version control/backup
Debugging Custom Liquid
Common Issues: Nothing displays:- Check for Liquid syntax errors (missing
%}, unclosed tags) - Verify objects exist (e.g.,
productonly exists on product pages) - Check padding isn’t set too low (content might be hidden)
- Validate HTML structure (unclosed tags break layout)
- Check for CSS specificity conflicts with theme styles
- Verify JavaScript isn’t conflicting with theme scripts
- Remove expensive operations (nested loops, large arrays)
- Limit external script/style includes
- Cache repeated calculations in variables
Security Best Practices
- Sanitize user input: Never directly output customer-submitted data without escaping
- Use
escapefilter:{{ user_input | escape }}prevents XSS attacks - Validate external resources: Only include scripts/styles from trusted sources
- Avoid inline credentials: Never hardcode API keys or passwords
- Test for injection attacks: Ensure form inputs can’t execute code
Performance Monitoring
After adding custom Liquid:- Use browser DevTools Network tab to check page load time
- Monitor server response time in Shopify admin (Online Store > Themes > Actions > Preview)
- Test on slow connections (DevTools network throttling)
- Check mobile performance (often slower than desktop)
Troubleshooting
Custom Liquid section is empty/not displaying:- Verify code is saved (click Save after editing)
- Check Liquid syntax for errors (unclosed tags, typos in object names)
- Ensure template context matches code (e.g.,
productobject only exists on product pages) - Check padding settings aren’t set to 0 with no content height
- Validate HTML structure (use W3C validator)
- Check for unclosed
<div>,<style>, or<script>tags - Verify custom CSS isn’t overriding critical theme styles
- Inspect with browser DevTools to identify conflicting styles
- Test responsive behavior (fixed widths may overflow)
- Check external resources load on mobile connections
- Verify JavaScript doesn’t rely on desktop-specific events
- Test iframe embeds (some services don’t work well on mobile)
- Remove or optimize nested Liquid loops
- Limit external script/style includes (each adds HTTP request)
- Cache repeated operations in variables rather than recalculating
- Consider moving heavy logic to snippet file with error handling
- Verify app is installed and enabled
- Check snippet name matches exactly (case-sensitive)
- Ensure app hasn’t been updated with new snippet name
- Review app’s integration instructions for template compatibility
- Check for syntax errors in
<script>tags - Verify jQuery/libraries are loaded if code depends on them
- Ensure code doesn’t conflict with theme’s existing JavaScript
- Wrap code in
DOMContentLoadedto ensure DOM is ready