Getting metafields title tag and description tag through API

Getting metafields title tag and description tag through API

Ryan92
Tourist
12 0 1

Hi,

I've been trying to fetch the seo meta title tag and description from a product to use it with my app. In documentation under product it says there is an attribute  metafields_global_title_tag and metafields_global_description_tag but it doesn't fetch anything. Any ideas?

 

Replies 8 (8)

Jason
Shopify Partner
11201 226 2311

Where did you see the format for those metafields shown as "metafields_global_title_tag". The correct reference  should appear like so :

metafields.global.title_tag

 

  • namespace: global
  • key: title_tag or description_tag

If a product has not been given a custom SEO title or SEO descripton those metafields won't exist.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★

Ryan92
Tourist
12 0 1

I saw it in the API reference under the product in the product properties table

Ryan92
Tourist
12 0 1

I found the answer, now the seem to appear on the endpoint admin/products/{ product_id }/metafields.json

Manuel5
Visitor
1 0 0

Ryan is right, thanks.

The doc is outdated https://help.shopify.com/api/reference/product

The keys `metafields_global_title_tag` and `metafields_global_description_tag` don't exist.

dobeerman
Visitor
1 0 0

Did anybody solve this issue with no keys?

Kevin_Williams
Excursionist
34 0 8

Try this:

{{ product.metafields.global.description_tag | default: product.description | strip_html | truncatewords: 150, '' }}

Truncation is optional and included if product description fallback is necessary.

beatihomeusa
Visitor
3 0 0

anyone knows how to change this????

global tag.png

maks-afew
Shopify Partner
8 0 2

In product admin scroll down to the "Search engine listing" and click "Edit". There you can set meta title and description in your default language