Metafield collections on collection page

Topic summary

A user is working to display metafield collections as a clickable grid/list on a Shopify collection page but initially struggled with implementation and image rendering.

Technical Challenge:

  • Goal: Display multiple collections stored in metafields on a specific collection page
  • Initial attempts failed to render collections as clickable elements with proper images and titles

Solution Development:

  • Community members suggested adding code to sections/main-collection-product-grid.liquid
  • Through collaboration and iteration, the user progressively refined the Liquid template code
  • Key issues resolved: collection images not pulling correctly, titles not displaying beneath categories

Final Outcome:

  • User successfully implemented a working solution displaying collections in a grid format
  • Shared final code for others facing similar customization needs
  • Live example available at the Somfy motors collection page
  • Code uses collection.metafields.custom.metafield_collections.value to retrieve and loop through collections, rendering images with proper sizing and clickable titles

Status: Resolved. User achieved desired layout and shared working code with community.

Summarized with AI on November 9. AI used: claude-sonnet-4-5-20250929.

Hi, i am trying to get the metafields i made that contain multiple collections that should show as a grid or list on the page but i can’t seem to figure out where to add the code. I was trying to add this code into collection list, but that didnt show them as collections you could click.

The link i am trying to currently add it to. is https://alanrichardtextiles.com/collections/somfy-motors-shades-blinds-awnings-curtains-projectors

{% assign metafield_collections = collection.metafields.custom.metafield_collections.value %}

{% for collection in metafield_collections %}

{{ collection.title }}

{% endfor %}

Hey Alan! Here is long shot!

{% assign metafield_collections = collection.metafields.custom.metafield_collections.value %}

{% if metafield_collections != blank %}
  
    {% for collection_handle in metafield_collections %}
      {% assign collection = collections[collection_handle] %}
      {% if collection != blank %}
        

          
            

              
            

            {{ collection.title }}

          
        

      {% endif %}
    {% endfor %}
  

{% else %}
  

No collections found.

{% endif %}

Hi @alanrichardtex ,

You try to add code to sections/main-collection-product-grid.liquid

{% assign metafield_collections = collection.metafields.custom.metafield_collections.value %}

    

        

            

                

                    ## 
                        Collection list
                    
                

            

        

    

    
        

            

                

                  {% for col in metafield_collections %}
                    

                        {% if col.image != blank %}
                        

                            

                                

                                    
                                        {{
                                            col.image
                                            | image_url: width: 3840
                                            | image_tag: height: height, sizes: sizes, widths: widths, fetchpriority: fetch_priority
                                          }}
                                    
                                

                            

                        

                        {% endif %}
                        
                            ####  {{ col.title }}
                        

                    

                {% endfor %}
                

            

        

    

1 Like

shows up, but not how it should and doesnt pull the picture. Bottom is how collections normally look, and the stuff on the left is whats being pulled from the metafields

so between what you just sent me and messing with AI a bit, this is what i came up with. its pretty much what i want, but i can’t get the titles to show up beneath each category. https://alanrichardtextiles.com/collections/somfy-motors-shades-blinds-awnings-curtains-screens

{% assign metafield_collections = collection.metafields.custom.metafield_collections.value %}

    

        

            {% for col in metafield_collections %}
                

                    

                        

                            

                                
                                    
                                
                            

                        

                        
                        

                        #### {{ col.title }}
                    

                

            {% endfor %}
        

    

Hi @alanrichardtex ,

You try to add code below to top file?


1 Like

that didnt work still. but i actually got it to work now using this code.

thank you for the help!

{% assign metafield_collections = collection.metafields.custom.metafield_collections.value %}

    

        

            {% for col in metafield_collections %}
               

    

                        

                            
                                
                            
                        

                        
                            #### {{ col.title }}
                        

                    

                    
                

            {% endfor %}

        

    

this is the final code i’ll be using after i did some more editing to it. now everything looks pretty nice and neat. heres the code incase anyone else wants to use it for something similar. you can view how it looks on this page https://alanrichardtextiles.com/collections/somfy-motors-shades-blinds-awnings-curtains-screens

{% assign metafield_collections = collection.metafields.custom.metafield_collections.value %}

    

        

           {% for col in metafield_collections %}
    {% assign imageSize = col.image | image_size %}
    {% assign imageWidth = imageSize[0] %}
    {% assign imageHeight = imageSize[1] %}
    {% assign maxImageSize = imageWidth | max: imageHeight %}
    {% assign backgroundSize = maxImageSize | append: "px" %}
    

        

            

                
                    

                
            

        

        
        
            #### {{ col.title }}
        

    

{% endfor %}