Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Is there any way to use the {{ collection.description }} object as a dynamic source in themes?
On collection templates, only the collection title is shown as an dynamic content source. Even if I manually add {{ collection.description }} to the template's .json file it throws up an error that the source is invalid.
Json:
Error:
Am I doing this wrong? I cant think of any reason why Shopify would exclude the collection description for the dynamic source options.
Update:
I've just been looking into this more and it seems like product templates are similarly limited to just the product title and vendor. What about all of the other product objects like description, type, tags etc? Seems strange that this has been limited to severely.
Very annoying that you cannot use {{ collection.description }} as a dymanic variable. The only way I was able to do this was to duplicate the section and code in this variable into the liquid file.
Steps
Hope this helps
Hello, thank you for suggestion. Please halp. Which section do we need duplicate to try and achieve same way as you did?
This is indeed a strange oversight. It's the same with product descriptions, they are not available as a dynamic source. So, if you want to output the description into another block or content section on the product template you have to basically set up a metafield for it and duplicate the description into the metafield.
Of course it's totally possible to output descriptions in liquid, but I think that isn't the point here. Dynamic sources are supposed to allow you to pull data dynamically in the theme without the need to work in liquid code. Otherwise why would we even care about dynamic sources if we are just going to go into the liquid code, right?
The main problem though with having to duplicate the description field into a metafield is that the rich content metafield type does not support all of the formatting options possible in the description field (eg: tables or nested lists). Perhaps that is the reason why they are not available as dynamic sources. But either way, this is a real limitation and I hope Shopify will resolve this soon. That said, dynamic sources have been around for a long time now. So it's take a while.
This is truly messed up. I want to put my product descriptions into the Collapsible row, but like you said, not possible without coding liquid and it defeats the purpose. I'm not going to go move hundreds of product descriptions into metafields. Why does Shopify overlook such simple stuff? Why did it take them a decade to add native Subscriptions? Why can't I dupicate a navigation menu? The list goes on and on. We don't get it.
@kriszti all valid points. And yet, we also have to admit that Shopify is still a fantastic platform to work with. It brings a lot to the table that other platforms require a plethora of plugins to achieve. Still, it is frustrating that there are certain specific things that Shopify does not seem to support, even though they seem simple.
I completely agree that this is frustrating. In the meantime I've just used the following solution:
Add the following schemda definition
{
"type": "checkbox",
"id": "show_product_desc",
"label": "Show product description",
"default": false
}
And add liquid code below to add a condition relevant to product/collection page:
{%- assign content = block.settings.content -%}
{% if block.settings.show_product_desc %}
{% if template == 'product' %}
{{ product.description }}
{% else %}
{{- content -}}
{% endif %}
{% else %}
{{- content -}}
{% endif %}
This way we can keep the option of only showing description where we want to. Hope it helps!
Update: I've realised, this is now possible without liquid coding. When you click on the dynamic source button, it gives you option to choose template in addition to default being page. Please see below:
Good luck!