# Metafields code adding a gallery

**URL:** <https://community.shopify.com/t/metafields-code-adding-a-gallery/646785>\
**Category:** Shopify Discussion\
**Tags:** metafields\
**Created:** [July 8, 2026, 11:05pm UTC](https://community.shopify.com/t/metafields-code-adding-a-gallery/646785 "2026-07-08T23:05:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sallie1978](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@sallie1978](https://community.shopify.com/u/sallie1978)\
**Post date:** [July 8, 2026, 11:05pm UTC](https://community.shopify.com/t/metafields-code-adding-a-gallery/646785/1 "2026-07-08T23:05:12Z")

</div>

I am hoping to use Metafields so I can add a different gallery to all my collections, I have looked at metafields but can’t see the most suitable field for the code, I try JSON but wouldn’t work, any suggestions. I have the gallery setup in an app and can copy the code across it works normally if I add as a custom liquid but not sure how to do it in metafields

---

<div class="post-metadata">

**Author:** ![devcoders](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/devcoders/32/403479_2.png) [@devcoders](https://community.shopify.com/u/devcoders)\
**Post date:** [July 9, 2026, 3:52am UTC](https://community.shopify.com/t/metafields-code-adding-a-gallery/646785/3 "2026-07-09T03:52:05Z")

</div>

Hi @sallie1978

Okay, can you send me the design you want? I’ll review it and then provide you with a proper update on how it can be implemented.

**Best regards,  
Devcoder 💻**

---

<div class="post-metadata">

**Author:** ![tim\_tairli](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/tim_tairli/32/283567_2.png) [@tim\_tairli](https://community.shopify.com/u/tim_tairli)\
**Post date:** [July 9, 2026, 4:09am UTC](https://community.shopify.com/t/metafields-code-adding-a-gallery/646785/4 "2026-07-09T04:09:05Z")

</div>

It’s a very general question.

Depends on what you want to show in your gallery.

General answer – “list of metaobject references” – this would allow you to cover any data, but maybe unnecessary complex.

JSON should be fine’ish too, but requires some coding experience to use properly.

“List of product references” can be fine to do stuff similar to “Featured collection” sections.

Do you have this app-based gallery somewhere on your site? – share a link to that page to get better understanding of what you want to accomplish.

---

<div class="post-metadata">

**Author:** ![Ploqo](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/ploqo/32/398219_2.png) [@Ploqo](https://community.shopify.com/u/Ploqo)\
**Post date:** [July 9, 2026, 7:47am UTC](https://community.shopify.com/t/metafields-code-adding-a-gallery/646785/5 "2026-07-09T07:47:34Z")

</div>

About metafields:

I tried putting liquid code, html, and javascript into the metafield’s value - only the html and javascript is rendered:

 ![image](https://canada1.discourse-cdn.com/shopifyforum/original/4X/d/b/e/dbeb054f4eeced64ec2b5d2b5f7d50e9bd2a6126.jpeg)  
 ![image](https://canada1.discourse-cdn.com/shopifyforum/original/4X/7/9/b/79b67eb70759cf986abafbe84ce1a72b1d26371c.jpeg)  
For liquid, the placeholder is printed as it is  
 ![image](https://canada1.discourse-cdn.com/shopifyforum/original/4X/0/2/7/0276d950aa7ac0a6a35968b9f1be6963e3a2be74.jpeg)

So,

- If your app gives you a plain **HTML/JS embed** (a `<div>` + `<script>`), a metafield works perfectly.
- If the code contains any **Liquid** (`{% ... %}` tags, `{{ ... }}` objects, or an app snippet/block reference), that part will print as plain text from a metafield instead of running.

**What you can do:**  
**Setup for a different gallery per collection (no editing the theme per collection):**

1. Settings \> Custom data \> Collections \> Add definition. Name it `Gallery code`, type **Multi-line text**. The key becomes `custom.gallery_code`.
2. Open each collection, paste that collection’s embed into the Gallery code field, Save.
3. In the theme editor, on your Collection template, add **one** Custom Liquid block/section with just:

```liquid
{{ collection.metafields.custom.gallery_code.value }}

```

Now every collection renders its own gallery automatically. Collections with an empty field show nothing, and you do not need to touch the theme again when you add a new collection.

**I Tested on a Dawn collection page:** pasted an embed into a `custom.gallery_code` multi-line text metafield and output it on the collection template. The HTML rendered and the embed’s `<script>` ran normally. When I dropped a Liquid tag (`{{ collection.title }}`) into the metafield it printed literally instead of executing, which confirms the point above.

If your app code is Liquid: keep it in a Custom Liquid block, but you can still drive it per collection by storing just a small value in the metafield (a gallery ID or handle) and branching on `{{ collection.metafields.custom.gallery_code.value }}` inside that block. And if the gallery is an app block rather than a plain embed, it may need the app’s own section/block to initialize rather than a raw paste.

---

<div class="post-metadata">

**Author:** ![sadik\_ShopiDevs](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/sadik_shopidevs/32/91853_2.png) [@sadik\_ShopiDevs](https://community.shopify.com/u/sadik_ShopiDevs)\
**Post date:** [July 9, 2026, 10:58am UTC](https://community.shopify.com/t/metafields-code-adding-a-gallery/646785/6 "2026-07-09T10:58:15Z")

</div>

Hello @sallie1978

For this setup, I would not use JSON unless the gallery app specifically requires JSON. A better approach is usually to create a **collection metafield** and then output that metafield inside your collection template.

You can try this:

1. Go to **Settings \> Custom data \> Collections**
2. Click **Add definition**
3. Create a metafield like this:

**Name:** Collection Gallery Code  
**Namespace and key:** `custom.gallery_code`  
**Type:** Multi-line text

Then go to each collection and paste the gallery embed/code into that metafield.

After that, go to your collection template and add a **Custom liquid** block where you want the gallery to appear, then use:

```liquid
{% if collection.metafields.custom.gallery_code != blank %}
  {{ collection.metafields.custom.gallery_code.value }}
{% endif %}

```

This should allow you to show a different gallery for each collection.

One important thing: if the gallery code contains Liquid code like `{% render %}`, `{% section %}`, or app snippet code, Shopify may not process that properly when it is stored inside a metafield. In that case, the better method is to store only the **gallery ID or handle** in the metafield, then use that value inside your theme code.

Another easier alternative is to use a gallery app that already supports showing different galleries on different collections. Many Shopify merchants use **[Essential Grid Gallery](https://app.partnerjam.com/install?key=49a5db1a-ff7c-4170-83a1-f26ecc91587b)**[](https://app.partnerjam.com/install?key=49a5db1a-ff7c-4170-83a1-f26ecc91587b)for this type of setup. Their support team is also very helpful, and if you give them collaborator access to your store, they can help set it up for you.

You can follow the [video tutorial](https://www.youtube.com/watch?v=1xPETdr4F3M&list=PL4s7zVgu3Whl7EtNYCJVWMzNyhBm_JSE2&index=18) or check the [step-by-step documentation](https://essential-grid.crisp.help/en/article/how-to-display-gallery-by-metafield-7eni43/?bust=1783591155633).

---

<div class="post-metadata">

**Author:** ![sallie1978](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@sallie1978](https://community.shopify.com/u/sallie1978)\
**Post date:** [July 9, 2026, 11:04pm UTC](https://community.shopify.com/t/metafields-code-adding-a-gallery/646785/7 "2026-07-09T23:04:39Z")

</div>

Thanks is from Robin Pro app, this is the code

---

<div class="post-metadata">

**Author:** ![tim\_tairli](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/tim_tairli/32/283567_2.png) [@tim\_tairli](https://community.shopify.com/u/tim_tairli)\
**Post date:** [July 10, 2026, 4:04am UTC](https://community.shopify.com/t/metafields-code-adding-a-gallery/646785/8 "2026-07-10T04:04:32Z")

</div>

You need to use the `</>` button to paste HTML code, otherwise forum engine will mangle it.  
Would be helpful to see it anyway.

* * *

Looks like I did not understand your goal properly – are you looking to store HTML code in metafield and output it later?

Than follow the @Ploqo guide above and mark his post as solution for others to find it faster.

But you can also follow the [app documentation](https://klimo.io/posts/how-to-embed-robin-pro-galleries/) and embed this HTML into collection description, given that it’s only a short code like this:

```auto
<div class="robin-pro" id="cb72c1d9-d362-46eb-8cf7-af0b85307746"></div>

```
