Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Requirement:
On the search page, we want to change how the item description appears. We want the search results to show the contents of the Meta Description instead of the Description. In the Product page, Meta Description will only show if you click the Edit website SEO link below, at the Search engine listing preview section.
What I checked:
1. In our search liquid template, the items are printed under this loop:
{% for item in search.results %}
2. The item description is printed as such:
{{ item.content | strip_html | truncatewords: 30 }}
3. In product object in Shopify.dev, there is no direct reference to Meta Description field. I'm also aware of the metafield object also included in the product object but it is different since Meta Description is a standard field in Shopify products, we did not create that.
4. I know about the page_description object, but it is not applicable to the search liquid template. Unless there is a way to open the item as a page within the loop and get the page_description?
5. Found this thread in this forum, but the solution is not applicable on my end.
Any suggestions on how to implement our requirement? Thank you.
Hi @ellekaie ,
The thing is that a product's meta description is indeed stored as a metafield:
Here's the link to the docs from my screenshot.
You can check it with a pretty simple test:
1) Create a dummy product without the meta and default description;
2) Use the Shopify admin API to access the list of metafields and see that there's no "description_tag" metafield for this product. Add the following code:
/metafields.json?namespace=global&key=description_tag
to the product URL while in the admin panel. As a result, the URL in the address bar would look like this:
Press enter.
3) Go back to the product editing page and add a test seo description.
4) Use the API just like we did in the second step of this list.
Since the data is stored as a metafield, you can access and display it's content on the product page with the following Liquid code:
{{ product.metafields.global.description_tag.value }}
Thank you so much! Will look into this.
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024