Schema mark up error

Solved
Chisty
Tourist
11 0 3

Any help appreciated.

I am getting an error reported via Google on the following,

Parsing error: Missing ',' or '}'

This is the code. 

The code works fine for the collection page, such as collection/ring, but it is reporting the above error if the URL includes a tag such as collection/ring/gold

<script type="application/ld+json">
{
"@context":
"https://schema.org/",
"@type":
"CreativeWorkSeries",
"name":
"{{ page_title }}{% if current_tags %} &ndash; tagged "{{ current_tags | join: ', ' }}"{% endif %}{% if current_page != 1 %} &ndash; Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} &ndash; {{ shop.name }}{% endunless %}",
"aggregateRating":
{
"@type":
"AggregateRating",
"ratingValue":
"5",
"bestRating":
"5",
"ratingCount":
"2031"
}
}</script>

 

Thanks in advance for your help

 

Chris

0 Likes
LitExtension
Shopify Partner
696 71 124

Hi @Chisty

Your problem is caused by this snippet:

"name":

"{{ page_title }}{% if current_tags %} &ndash; tagged "{{ current_tags | join: ', ' }}"{% endif %}{% if current_page != 1 %} &ndash; Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} &ndash; {{ shop.name }}{% endunless %}",

You need re-check this snippet. 

Hope this helps! 

LitExtension - Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
0 Likes
Chisty
Tourist
11 0 3

Thank you for your reply. Yes that was my query. I am not sure what is wrong with that part of the code that is causing the google error report. It works fine unless there is a tag on the initial query.

0 Likes
Quyen_Beo
Explorer
58 7 12

"name":
"{{ page_title }}{% if current_tags %} &ndash; tagged "{{ current_tags | join: ', ' }}"{% endif %}{% if current_page != 1 %} &ndash; Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} &ndash; {{ shop.name }}{% endunless %}",

When having the tag, the real string will become kind like this
"name": "Page title here - tagged "tag1,tag2,tag3" - more content here"

As you can see there are double quote "" inside another quote "", which make the error I think.

You should try to print/log that string to check what is the real value you passed in.

Was my reply helpful? Please Like and ✔️ Accept Solution. This mean alot to me
0 Likes
Chisty
Tourist
11 0 3

I have tried altering the code but can't get it to work on this query.

Is this what you meant?

 

"name":
"{{ page_title }}{% if current_tags %} &ndash; tagged {{ current_tags | join: ', ' }}{% endif %}{% if current_page != 1 %} &ndash; Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} &ndash; {{ shop.name }}{% endunless %}",

0 Likes
Quyen_Beo
Explorer
58 7 12

The tags should still be in the quote but not the double quote because it will conflict with the parent quote

You can try this

 

"name":
"{{ page_title }}{% if current_tags %} &ndash; tagged '{{ current_tags | join: ', ' }}'{% endif %}{% if current_page != 1 %} &ndash; Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} &ndash; {{ shop.name }}{% endunless %}",

Was my reply helpful? Please Like and ✔️ Accept Solution. This mean alot to me
0 Likes
LitExtension
Shopify Partner
696 71 124

This is an accepted solution.

Hi @Chisty

You can use this snippet to solve your problem:

{

  "@context": "https://schema.org/",

  "@type": "CreativeWorkSeries",

  "name": "{{ page_title }}{% if current_tags %} &ndash; tagged {{ current_tags | join: ', ' }}{% endif %}{% if current_page != 1 %} &ndash; Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} &ndash; {{ shop.name }}{% endunless %}",

  "aggregateRating": {

    "@type": "AggregateRating",

    "ratingValue": "5",

    "bestRating": "5",

    "ratingCount": "2031"

  }

}

Hope this helps! 

LitExtension - Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
Chisty
Tourist
11 0 3

Thank you very much for that. I appreciate your time. I used your code and put it through the "validate fix" on GSC. It returned the same error

0 Likes
Chisty
Tourist
11 0 3

Thank you, I have added that and "validated the fix" on GSC, just waiting back on that validation from Google. 

0 Likes