Liquid & Code HelpSolved
Liquid: how to output only metafield values that aren't empty in a clean list?
Devraj Pillai·Asked May 26, 2026
I have ~8 product metafields (custom.feature_1 through custom.feature_8) used as bullet-point features. Some products have all 8 filled, some have only 3. Currently I'm rendering them like:
{% if product.metafields.custom.feature_1 != blank %}
<li>{{ product.metafields.custom.feature_1 }}</li>
{% endif %}
{% if product.metafields.custom.feature_2 != blank %}
...
This is ugly and unmaintainable. Is there a way to iterate metafields by prefix, or a cleaner pattern? Open to restructuring how the metafields are stored too if it helps.