Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello guys,
How can i create custom metafields in order to display an HTML CSS styled nutritional table on the product page.
My idea is to fill the nutritional metafields on each product page and a table is automatically rendered on the front-end.
Thank you very much
Hi @joaquimoliveira,
With this, I recommend to display images instead of HTML and CSS, it will be simpler for you.
You can follow the steps of the following article: https://community.shopify.com/c/shopify-design/dawn-theme-collapsible-row-with-image-size-chart/td-p...
With step 4 you just change the code to:
<img src="{{ product.metafields.my_fields.size_guide | img_url: 'master' }}" alt="Top Notes" width="530">
Hope it helps!
Thanks for the reply but that does not solve my problem because i want the innformation to be crawlable by search engines and i dont want to upload my website with images.
Hi @joaquimoliveira,
If you don't want to use images, do you have HTML experience?
Instead of creating Metafields image you can create Metafields text and then add HTML at each product, it will work the same.
Hope it helps!
Can i create an HTML table with metafields inside?
Which metafield option do i choose to input a table?
thank you
You could create a product metafield of type text, call it 'ingredients'. For each of your products add a comma separated list of the ingredients to the new metafield (eg. ingredient1, ingredient2, ingredient3,...). Then use this liquid code to display the list of ingredients:
{%- assign ingredients = product.metafields.my_fields.ingredients | split:"," -%}
<table>
{% tablerow ingredient in ingredients cols: 1 %}
{{ ingredient }}
{% endtablerow %}
</table>
Then add some css styles for the table.
Have a look at the liquid iterator tags here: https://shopify.dev/api/liquid/tags/iteration-tags#cycle
There's some good options using the 'cycle' tag for styling.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024