Have your say in Community Polls: What was/is your greatest motivation to start your own business?

JSON LD Schema does not work on international pages

Solved

JSON LD Schema does not work on international pages

Jim_Borchardt
Excursionist
14 1 2

Hello everyone, 

My JSON LD schema markup works great on my domestic pages and has been validated with Rich Results Test / Schema.org validator. 

However, once I go to an international version of a page on my website (subfolder directory - example.com/en-au/ ), the Schema is no longer populating the page HTML nor is it showing up in validators. 

What's happening here? 

To explain my set up further: 

  • I create JSON LD schema in a snippet
  • I render said snippet in relevant section from which snippet is pulling dynamic values 
  • Rendering is based on tail end of page path, well beyond the subdirectory path
    • For example if the page is example.com/collections/mens-shoes or example.com/en-au/collections/mens-shoes, I render snippet based on /collections/mens-shoes
  • All my subdirectories are in english 

 

Appreciate any insight! Thanks

Accepted Solution (1)

Jim_Borchardt
Excursionist
14 1 2

This is an accepted solution.

Well for anyone having this issue, I have solved it myself. I was rendering the snippets incorrectly based on page path.

For example:

Incorrect:

{%- if request.path == '/collections/mens-shoes' -%}
 {% render 'schema-mens-shoes' %}
{%- endif -%}

 

Correct:

{%- if request.path contains '/collections/mens-shoes' -%}
 {% render 'schema-mens-shoes' %}
{%- endif -%}


Notice in the correct example I use contains instead of ==

I incorrectly assumed that just leaving the tail end of page path would leave room for whatever sub-directory.

View solution in original post

Replies 2 (2)

Jim_Borchardt
Excursionist
14 1 2

This is an accepted solution.

Well for anyone having this issue, I have solved it myself. I was rendering the snippets incorrectly based on page path.

For example:

Incorrect:

{%- if request.path == '/collections/mens-shoes' -%}
 {% render 'schema-mens-shoes' %}
{%- endif -%}

 

Correct:

{%- if request.path contains '/collections/mens-shoes' -%}
 {% render 'schema-mens-shoes' %}
{%- endif -%}


Notice in the correct example I use contains instead of ==

I incorrectly assumed that just leaving the tail end of page path would leave room for whatever sub-directory.

PaulNewton
Shopify Partner
7450 657 1565

Also see https://shopify.dev/docs/storefronts/themes/markets/multiple-currencies-languages

https://shopify.dev/docs/api/liquid/objects/localization

and request.origin etc https://shopify.dev/docs/api/liquid/objects/request#request-origin 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org