Sometimes, merchants need to add additional content to their storefronts beyond Shopify’s limitations. In this situation, using metafields is the only solution.
What is metafield?
A metafield is additional information beyond what is standard in Shopify, such as custom text, images, or even structured data. By using it, you can add extra details to products, customers, orders, or other entities.
What is rich text?
Rich text on Shopify allows you to format text with styles like bold, italic, and headings, as well as add links and lists. It’s a way to create visually appealing content for your store without needing to know coding (HTML or CSS).
How to add rich text metafield?
I assume you want to add a rich text metafield on your product page. Here are the steps to do so:
-
- Log in to your Shopify admin and click on “Settings”.
- In the left-hand menu, select “Custom data”.
- Under “Metafield definitions”, click on “Products”.
- Click the “Add field” button.
- Name the metafield and add a description (optional).
- From the “Select type” dropdown menu, choose “Rich text”.
- Ensure that “Storefront” is checked under “Options” (by default it is generally checked).
- Save the metafield definition.
How to populate metafield’s definition with data?
After creating your rich text metafield, the next step is to fill it with content. Here’s how:
- Go to your Shopify admin and then select “Products”.
- Choose the product to which you want to add the rich text metafield value.
- Now go to the “Metafields” section.
- Click on the field next to the “Rich text” (it also has the name you have given) metafield and add your content.
- Save the product.
Great! With that done, the rich text metafield value is now associated with your product, and you can easily display it on your storefront.
How to display rich text metafield values on the storefront?
There are two ways to display rich text metafield values on your storefront:
- No-code solution (inserting the rich text metafield value as a dynamic source)
- Code solution (rendering rich text metafield value with Liquid code)
In this tutorial, we’ll be focused on the no-code solution. It’s the easy solution, but you must remember one thing: rich text metafields can only be rendered in blocks (of your theme) that support rich text.
Here are the steps to do that:
-
- From the Shopify admin, go to “Customize”.
- Click on any product to go to the product template (default or any other).
- Add a new section in your template that supports rich text, such as a “Rich text” or “Image with text” section.
- Click the text block within the section, and then click the “Insert dynamic source” icon.
- Choose the rich text metafield that you have created.
- You should now see the rich text metafield value displayed on your storefront.
That’s all 🙂