d
Topic
Posts:
3
August 16, 2013
g
1
upvotes

Get product’s SEO information in Liquid This post is outdated

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.

 

i
Replies
Posts:
4
August 18, 2013

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/

 

Posts:
3
Last edited August 18, 2013
g
1
upvotes

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!

jduff Shopify Employee
Posts:
10
August 28, 2013
g
1
upvotes

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

Posts:
3
August 28, 2013

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

Posts:
5840
August 28, 2013
g
2
upvotes

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