Shopify Collection Customization: Adding Dynamic Sections with Metafields on Dawn 2.0
Hey there, fellow store owners! Navigating the ins and outs of Shopify theme customization can sometimes feel like solving a puzzle, especially when you want to add something truly unique to your store. Recently, a great discussion popped up in the Shopify Community that really highlighted a common challenge: how to add a custom section to a collection page, particularly one that uses dynamic content from metafields. Let's dive into what we learned from @Pickleball2's journey and the brilliant insights shared by other experts like @sadik_ShopiDevs, @Maximus3, and @Laza_Binaery.
Pickleball2, who runs www.pickleballbella.com on Dawn 2.0, was trying to add a new section that would display content based on collection metafields. The goal was to only show this section if the metafield had data, keeping things clean and dynamic. Sounds straightforward, right? Well, a few hurdles came up, which is totally normal when you're digging into theme code!
The Core Misunderstanding: JSON vs. Liquid
One of the biggest takeaways from the thread, articulated so well by @Maximus3 and @ajaycodewiz, is the fundamental difference between the JSON template files (like templates/collection.json) and your Liquid section files (like sections/my-custom-section.liquid). Think of it this way:
- JSON Templates (e.g.,
collection.json): These files are like the blueprint or table of contents for your page. They tell Shopify which sections to load and in what order. They do not contain any Liquid code, HTML, or direct logic for displaying content. - Liquid Section Files (e.g.,
sections/pbb-collection-hero-carousel.liquid): These are the actual building blocks. They contain all the HTML, CSS, JavaScript, and crucially, the Liquid code that renders your dynamic content, checks metafields, and defines settings for the Theme Customizer.
Pickleball2 initially tried to put Liquid logic directly into the collection.json file, which led to "file save errors." This is a classic mistake because JSON has a very strict format, and Liquid code will break it. As @sadik_ShopiDevs rightly pointed out, a single missing comma can invalidate the whole template!
Adding Your Custom Section: Two Paths to Take
The community offered two primary ways to add your custom section. For most store owners, the first method is usually the easiest and safest.
Method 1: The Theme Customizer Way (Recommended!)
This is generally the best approach for Online Store 2.0 themes (like Dawn) because it's visual and less prone to syntax errors. Shopify handles the JSON updates for you.
-
Create Your Section File: First, create your custom section file in your theme's
sectionsfolder. Let's say you name itsections/pbb-collection-hero-carousel.liquid. This file will contain your HTML, Liquid logic (like checking for metafields), and its schema. For example, Pickleball2's section looked something like this:{% if collection.metafields.custom.hero_images.value != blank %} {% render 'collection-hero-carousel' %} {% elsif collection.image %} {% render 'collection-featured-image' %} {% else %} {% render 'collection-header' %} {% endif %} {% schema %} { "name": "Collection Hero", "settings": [], "presets": [ { "name": "Collection Hero" } ], "enabled_on": { "templates": ["collection"] } } {% endschema %}Notice the
{% schema %}block at the bottom. This is crucial! For your section to appear in the Theme Customizer, you need a schema. The"enabled_on": { "templates": ["collection"] }part tells Shopify this section is available for collection templates. -
Add via Theme Customizer:
- Go to your Shopify admin: Online Store → Themes.
- Find your current theme and click Customize.
- In the customizer, navigate to a collection page (e.g., by selecting Collections → Default collection from the dropdown at the top).
- In the left sidebar, click Add section.
- Your new section (e.g., "Collection Hero" from the schema above) should now appear in the list! Select it.
- Drag and drop it to your desired position on the page.
- Click Save. Shopify will automatically update the underlying
collection.jsonfile for you. Easy peasy!
Method 2: Manually Editing the JSON Template (Use with Caution!)
If you're comfortable with code and need more precise control, you can edit the JSON template directly. Always, always, always duplicate your theme first before making direct code edits! This way, you have a backup if something goes wrong.
-
Duplicate Your Theme: Go to Online Store → Themes, find your theme, click Actions → Duplicate.
-
Create Your Section File: Just like in Method 1, create your
sections/pbb-collection-hero-carousel.liquidfile with its Liquid logic and schema. -
Edit the JSON Template:
- Go to Online Store → Themes, click Actions → Edit code for your duplicated theme.
- Navigate to
templates/collection.json. If you want a custom template for specific collections, you can create a new one, e.g.,templates/collection.custom-hero.json. - Inside the
"sections"object, add a new entry for your section. The key (e.g.,"carousel") is an internal ID you choose. The"type"must exactly match your section filename (without.liquid). - Then, add your chosen internal ID to the
"order"array where you want it to appear.
Here's an example of how it might look, similar to what @sadik_ShopiDevs and @ajaycodewiz demonstrated:
{ "sections": { "banner": { "type": "main-collection-banner", "settings": { "...": "..." } }, "carousel": { "type": "pbb-collection-hero-carousel", "settings": { "color_scheme": "scheme-053ea910-6eb4-4198-8577-e17b5ab7c241" } }, "product-grid": { "type": "main-collection-product-grid", "settings": { "...": "..." } } }, "order": ["banner", "carousel", "product-grid"] }Remember that crucial comma after
"banner": { ... },before your new"carousel": { ... }section! Missing commas are often the cause of "file save errors." Also, each item in the"order"array needs to be a string, separated by commas, like"carousel", "banner", "product-grid". -
Assign Custom Template (If Applicable): If you created a new template (e.g.,
collection.custom-hero.json), you need to assign it to your collections. Go to Online Store → Collections, select a collection, and under "Theme template," choose your new template from the dropdown.
The Missing Snippet Saga
Pickleball2 also ran into a "Liquid error (sections/pbb-collection-hero-carousel line 6): Could not find asset snippets/collection-header.liquid." This is a common hiccup when reusing code snippets from different themes or sources. As @Laza_Binaery correctly identified, this error means your section file is trying to {% render 'collection-header' %} a snippet that doesn't exist in your theme's snippets folder. You'll need to either:
- Create a file named
snippets/collection-header.liquidand put the appropriate code in it. - Or, if that snippet was for an old theme, remove or replace that
rendercall with something that does exist in your current theme (likecollection-banneror a custom snippet you create).
Remember, sections can render snippets, but snippets themselves don't have schemas and can't be added directly to the Theme Customizer.

Leveraging Metafields for Dynamic Content
Pickleball2’s core requirement was to show the section only if a metafield was populated. This is where metafields truly shine! The community quickly clarified that the correct way to access collection metafields in your section file is using syntax like {{ collection.metafields.custom.your_field.value }}.
Steps for Metafield Integration:
-
Define Your Metafield:
- In your Shopify admin, go to Settings → Custom data → Collections.
- Click Add definition.
- Give it a name (e.g., "Hero Images") and a namespace and key (e.g.,
custom.hero_images). The "custom" namespace is generally a good practice for custom fields. - Choose the content type that matches your needs (e.g., "File" for images, "Rich text" for formatted text).
- Save your definition.
-
Populate the Metafield:
- Go to Online Store → Collections and select the collection you want to customize.
- Scroll down to the "Metafields" section.
- Fill in the value for your newly defined metafield.
-
Add Conditional Logic to Your Section: In your
sections/pbb-collection-hero-carousel.liquidfile, use an{% if %}statement to check if the metafield has a value before rendering anything. This is exactly what Pickleball2 was aiming for:{% if collection.metafields.custom.hero_images.value != blank %} {% render 'collection-hero-carousel' %} {% else %} {% render 'collection-header' %} {% endif %}
This ensures your section only appears when there's actual content to display, keeping your collection pages clean and optimized. It's a fantastic way to add dynamic banners, promotional content, or unique imagery to specific collections without hardcoding it everywhere.

The journey to deeply customize your Shopify store can be incredibly rewarding, allowing you to create unique experiences for your customers. If you're just starting out or looking to enhance your existing store, remember that Shopify offers a powerful platform for growth. You can start your own Shopify store and dive into these customization possibilities. By understanding the distinction between JSON templates and Liquid sections, and mastering the use of metafields, you're well on your way to becoming a true Shopify customization pro. Don't be afraid to experiment (on a duplicated theme, of course!) and lean on the community for those tricky bits!