What this section controls
This section controls custom code integration with the following capabilities:- Custom Liquid templating code execution
- HTML, CSS, and JavaScript insertion
- Access to all Shopify Liquid objects (shop, product, collection, cart, customer)
- Liquid filters and logic operations
- Metafield data display
- Third-party script integration
- Color scheme selection for section container
- Width and spacing controls
Settings
Custom Liquid Code
Type: Liquid code editorPurpose: Enter custom Liquid, HTML, CSS, or JavaScript code This multi-line code editor accepts:
- Liquid - Shopify templating language (
{{ }},{% %}tags) - HTML - Structure and content markup
- CSS - Inline styles (wrap in
<style>tags) - JavaScript - Client-side functionality (wrap in
<script>tags)
shop- Store informationproduct- Current product (on product pages)collection- Current collection (on collection pages)cart- Cart datacustomer- Logged-in customer data- All global Liquid objects and filters
Common Settings
Color Scheme
Color Scheme
Options: Theme color schemes (scheme-1, scheme-2, etc.)
Default: scheme-1Purpose: Apply background and text colors from theme’s color scheme to the custom liquid section container.Note: Custom CSS within your liquid code can override these colors.
Default: scheme-1Purpose: Apply background and text colors from theme’s color scheme to the custom liquid section container.Note: Custom CSS within your liquid code can override these colors.
Section Width
Section Width
Options:
- Page - Standard page width container
- Fluid - Full-width with padding
- Full - 100% width, no padding
Spacing Top
Spacing Top
Options: None, S, M, L, XL
Default: MVertical margin above section. See Common Settings for details.
Default: MVertical margin above section. See Common Settings for details.
Spacing Bottom
Spacing Bottom
Options: None, S, M, L, XL
Default: MVertical margin below section. See Common Settings for details.
Default: MVertical margin below section. See Common Settings for details.
Section Border
Section Border
Options: None, Top, Bottom, Both
Default: NoneAdd decorative borders above/below section. See Common Settings for details.
Default: NoneAdd decorative borders above/below section. See Common Settings for details.
Use Cases
Custom Product Grid
Display products from specific collection with custom layout, filtering, or sorting logic using Liquid loops and conditionals.
Metafield Display
Show custom metafields (size charts, specifications, certifications) that aren’t natively supported by theme sections.
Dynamic Banners
Create conditional banners that display based on cart value, customer tags, product availability, or other dynamic data.
Third-Party Widgets
Embed widgets from external services (analytics, chat, tracking pixels) that require custom HTML/JavaScript.
Custom Calculations
Build product configurators, price calculators, or bundle pricing displays with Liquid math filters.
Advanced Filtering
Create custom collection filters beyond theme’s built-in options using Liquid conditionals and product tags.
Examples
Display Products from Collection
Show Metafield Data
Conditional Banner Based on Cart Value
Custom HTML/CSS/JavaScript Widget
Best practices
Test in Development Theme
Always test custom liquid code in a development/preview theme before publishing to live store. Errors can break your storefront.
Comment Your Code
Add comments explaining what code does. Makes troubleshooting easier:
{% comment %}Show products from summer collection{% endcomment %}Validate HTML/CSS
Use validators (W3C HTML Validator, CSS Validator) to check code syntax before deploying.
Optimize Images
Use Liquid image filters (
image_url, image_tag) with width/height parameters to serve optimized images.Handle Missing Data
Use conditionals to check if data exists before displaying:
{% if product.metafields.custom.size_chart %}Keep Code Maintainable
Break complex logic into smaller snippets. Reuse snippets with
{% render 'snippet-name' %} for cleaner code.Performance Considerations
Avoid heavy Liquid loops (e.g., looping through all products). Limit API calls and external scripts to maintain fast load times.
Mobile Responsiveness
Test custom layouts on mobile devices. Use CSS media queries or responsive grid layouts for mobile compatibility.
Liquid Resources
Official Documentation
- Shopify Liquid Documentation - Complete Liquid reference
- Liquid Objects - Available objects (product, shop, cart, etc.)
- Liquid Filters - Data manipulation filters
- Liquid Tags - Control flow and logic
Learning Resources
- Shopify Liquid Cheat Sheet - Quick reference guide
- Liquid Code Examples - Community examples on GitHub
- Shopify Partners Blog - Tutorials and best practices
Troubleshooting
Code doesn't display or breaks layout
Code doesn't display or breaks layout
Common causes:
- Syntax error in Liquid code (missing
{% endif %}, unmatched tags) - Unclosed HTML tags (
<div>without</div>) - JavaScript errors (check browser console)
- Check for syntax errors (missing closing tags, typos)
- Use browser developer tools (F12) to check console for JavaScript errors
- Validate HTML/CSS with online validators
- Remove code and add back section by section to isolate error
Liquid objects don't work (e.g., {{ product.title }} is blank)
Liquid objects don't work (e.g., {{ product.title }} is blank)
Possible causes:
- Object not available in current page context (e.g.,
productobject only on product pages) - Incorrect object/property name
- Object is nil/null (data doesn’t exist)
- Check Liquid Objects documentation for object availability
- Use conditionals to check if object exists:
{% if product %}{{ product.title }}{% endif %} - Verify property names match Liquid documentation
Custom CSS not applying
Custom CSS not applying
Solution:
- Ensure CSS wrapped in
<style>tags - Check CSS specificity (theme styles may override custom CSS)
- Use
!importantsparingly to force styles (not recommended long-term) - Inspect element in browser to see which styles are applied/overridden
JavaScript not executing
JavaScript not executing
Solution:
- Ensure JavaScript wrapped in
<script>tags - Check browser console (F12 → Console tab) for errors
- Verify DOM elements exist before manipulating (
getElementByIdreturns null if element doesn’t exist) - Use
DOMContentLoadedevent to ensure page loaded before running scripts
Section looks different than expected
Section looks different than expected
Solution:
- Theme’s global styles may conflict with custom code
- Check Common Settings (Color Scheme, Section Width) which affect container styles
- Use custom CSS classes to override theme styles
- Test with Section Width set to “Full” to remove container constraints
Security & Performance
Performance tips:- Limit Liquid loops (e.g.,
limit: 10instead of looping all products) - Use lazy loading for images
- Minimize external scripts and API calls
- Cache dynamic data when possible (use metafields for static data)
Related Sections
- Custom Liquid (Shopify Docs) - Official Liquid documentation
- Common Settings - Section-level styling options
Key Takeaways
- Requires Liquid knowledge - Advanced feature for developers or technical users
- Test before deploying - Always test in development theme to avoid breaking live store
- Access to Liquid objects - Full access to shop, product, cart, customer data
- HTML/CSS/JavaScript supported - Build custom layouts, styles, and functionality
- Flexible width options - Page, Fluid, or Full width for different layout needs
- Handle missing data - Use conditionals to check data exists before displaying