Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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 %} – tagged "{{ current_tags | join: ', ' }}"{% endif %}{% if current_page != 1 %} – Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} – {{ shop.name }}{% endunless %}",
"aggregateRating":
{
"@type":
"AggregateRating",
"ratingValue":
"5",
"bestRating":
"5",
"ratingCount":
"2031"
}
}</script>
Thanks in advance for your help
Chris
Solved! Go to the solution
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 %} – tagged {{ current_tags | join: ', ' }}{% endif %}{% if current_page != 1 %} – Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} – {{ shop.name }}{% endunless %}",
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "5",
"bestRating": "5",
"ratingCount": "2031"
}
}
Hope this helps!
Hi @Chisty,
Your problem is caused by this snippet:
"name":
"{{ page_title }}{% if current_tags %} – tagged "{{ current_tags | join: ', ' }}"{% endif %}{% if current_page != 1 %} – Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} – {{ shop.name }}{% endunless %}",
You need re-check this snippet.
Hope this helps!
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.
"name":
"{{ page_title }}{% if current_tags %} – tagged "{{ current_tags | join: ', ' }}"{% endif %}{% if current_page != 1 %} – Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} – {{ 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.
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 %} – tagged {{ current_tags | join: ', ' }}{% endif %}{% if current_page != 1 %} – Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} – {{ shop.name }}{% endunless %}",
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 %} – tagged '{{ current_tags | join: ', ' }}'{% endif %}{% if current_page != 1 %} – Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} – {{ shop.name }}{% endunless %}",
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
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 %} – tagged {{ current_tags | join: ', ' }}{% endif %}{% if current_page != 1 %} – Page {{ current_page }}{% endif %}{% unless page_title contains shop.name %} – {{ shop.name }}{% endunless %}",
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "5",
"bestRating": "5",
"ratingCount": "2031"
}
}
Hope this helps!
Thank you, I have added that and "validated the fix" on GSC, just waiting back on that validation from Google.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024