Get product’s SEO information in Liquid

Highlighted
Tourist
3 0 2

Let’s say I have this code:

{% for product in collection.products %}
  {{ product.title }}
{% endfor %}

And I also want to display the value of the  “Page description” SEO field for each product in the loop. Not the current page’s description, but the one entered in the product details form.

Is there any way to do that? Nothing in the documentation seems to reference it.

 

1 Like
Shopify Partner
4 0 0

To clarify, lets say you just uploaded a product and you titled it Blue Box. And then for the product description you put, "This is a Blue Box hand crafted in Costa Rica, you should buy." On your collections page in your product loop you want your product title, Blue Box, to display along with your product description, "This is a Blue Box hand crafted in Costa Rica, you should buy."?

If so use {{product.description}}


{% for product in collection.products %}

    {{ product.title }}

   {{product.description}}

{% endfor %}
 

Mark's cheat sheet helps me out a bunch. http://cheat.markdunkley.com/

 

0 Likes
Tourist
3 0 2

Thanks for your reply, but this is not the product’s description I want to display in the loop. I want to display the product SEO Page Description field. This one:

Thank you!

1 Like
Shopify Staff
Shopify Staff
10 0 2

Try:

{% assign instructions = product.metafields.global %}

{{ instructions.description_tag }}
{{ instructions.title_tag }}

You can probably do this as well:

{{ product.metafields | to_json }}

To dump them all out as json

1 Like
Tourist
3 0 2

Yep, that did the trick. Thank you so much for your help!

0 Likes
Shopify Staff
Shopify Staff
5826 0 263

For code that says what it is, I'd use:

{% assign seo_data = product.metafields.global %}

{{ seo_data.description_tag }}
{{ seo_data.title_tag }}

Or you can just use:

{{ product.metafields.global.description_tag }}
{{ product.metafields.global.title_tag }}

 

Caroline from http://11heavens.com ∴ mllegeorgesand AT gmail DOT com
2 Likes