Populating variant color for schema

Hi! im looking to populate a schema markup I’ve been writing for a product page, I got everything working well aside from one thing, color, I manage to get the first, default size of a product but I can’t get the color to populate in the schema, with my attempts I got it to either come back empty or at best with the product size rather than the color.

Do you have any ideas why?

P.S. Each product page has the color at the title, I looked at the code for H1 in the main-product.liquid but I couldn’t figure out the dynamic part of the code that adds the color.

Hi Shay,

I’m not super clear on what you’re trying to do - in this case colors are variants and you’re looking to set these up on the product page? Is this related to color schemes? Input settings

Also, which theme are you using?

im trying to output schema markup/structured data, in JSON format, I’m not looking to set color, just to pick the first color that is on the list (default variant?, Im not entirely sure what it is called)

so basically its a JSON that will be set in the main-product.liquid code, it will have shopidy codex/internal shortcodes implemented in the fields of the JSON script and with that at the HTML code of each page on the front end.

so I’ve used Shopify shortcodes in all the fields of the json code and the data is being populated properly except for one value, the color.

so for example, if I browse the website and I go to a page about brown teddy bears, in the HTML code (only, not presented on the frontend/page itself) I would be able to see a script in JSON format with all the information that is in the page, one field will be “color” and the value should be “brown” even if there are other color variants available in the page by clicking on them, I want to pick only the first available/default color of the teddy bear.

If you add .json to the url of the rendered product page, it should give you the full product data in json format - would that work instead?

Sadly no, I do see that it outputs a lot of information about the product. I guess we could set a code that will process the data and filter out everything but the color of the product and that way pass it to the color field in the schema, however, even in that .json output I don’t see any reference to color aside from the URL and image file name which makes it unreliable in case the URL or image file name doesn’t match the actual product color.

which still makes me wonder why there are handles/shortcodes like “{{ shop.url }}” and “{{ product.description }}” and others that work perfectly but have nothing like “{{ product_color }}”