Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I have product pages that use a modified template. Template has had slight modifications, nothing big, really.
However, it has code that's coming from a structured-data.liquid file that was NOT modified.
The output on the website would for example be:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Product",
"offers": [{
"@type": "Offer",
"name": "Default Title",
"availability":"https://schema.org/InStock",
"price": "12.34",
"priceCurrency": "USD",
"priceValidUntil": "2025-02-01","sku": "PRODX","url": "/products/item1/products/item1?variant=12345"
I've looked up where it would come from and it comes from that file. However, the url in question is just (outside of the variant) {{request.path}}
As you can see in the example above, it DOUBLES the path.. it should've been "/products/item1" and not "/products/item1/products/item1". Why is it doing this? Is there a way to prevent this from happening?
(most people won't notice it.. but Google picks up this path and then throws an error that it cannot be found..)
Solved! Go to the solution
This is an accepted solution.
autoBlogger: Seamlessly scheduled, fully automated, AI-powered, and SEO-optimised blogging with FAQs, table of contents and other features! Start your 14-day free trial today!
autoSchema: Fully automated and continuously updated Google structured data, including duplicate data removal. Simple to install – try it now!
Hey
Do you mind sharing the structured-data.liquid code that is being used to generate this script. I can take a look.
autoBlogger: Seamlessly scheduled, fully automated, AI-powered, and SEO-optimised blogging with FAQs, table of contents and other features! Start your 14-day free trial today!
autoSchema: Fully automated and continuously updated Google structured data, including duplicate data removal. Simple to install – try it now!
Sure. Thing is.. that file came with the theme (Envy) and the file is structured-data.liquid. Not modified...
Part of the code in there is:
{%- capture main_entity_microdata -%}
"@type": "Product",
"offers": [
{%- for variant in product.variants -%}
{
"@type": "Offer",
"name": {{ variant.title | json }},
"availability": {%- if variant.available -%}"https://schema.org/InStock"{%- else -%}"https://schema.org/OutOfStock"{%- endif -%},
"price": {{ variant.price | money_without_currency | json }},
"priceCurrency": {{ shop.currency | json }},
"priceValidUntil": "{{ 'now' | date: '%s' | plus: days_product_price_valid_until | date: '%Y-%m-%d'}}",
{%- if variant.sku != blank -%}
"sku": {{ variant.sku | json }},
{%- endif -%}
"url": "{{ request.path }}{{ variant.url }}"
}{% unless forloop.last %},{% endunless %}
{%- endfor -%}
],
{%- if is_barcode_available and is_valid_gtin_length %}
"{{gtin_option}}": {{ product.selected_or_first_available_variant.barcode | json }},
"productId": {{ product.selected_or_first_available_variant.barcode | json }},
{%- elsif is_barcode_available %}
"mpn": {{ product.selected_or_first_available_variant.barcode | json }},
"productId": {{ product.selected_or_first_available_variant.barcode | json }},
{% else %}
"productId": {{ product.id | json }},
{%- endif %}
{%- if has_reviews -%}
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "{{ rating_value }}",
"reviewCount": "{{ review_count }}"
},
{%- endif %}
"brand": {
"name": "{{ product.vendor }}"
},
"name": {{ product.title | json }},
"description": {{ product.description | strip_html | json }},
"category": {{ product.type | json }},
"url": "{{ request.path }}{{ product.url }}",
"sku": {{ product.selected_or_first_available_variant.sku | json }},
"image": {
"@type": "ImageObject",
"url": "https:{{ product.featured_image | img_url: '1024x' }}",
"image": "https:{{ product.featured_image | img_url: '1024x' }}",
"name": {{ product.featured_image.alt | json }},
"width": "1024",
"height": "1024"
}
You'll fine request.path in there twice. Interestingly variant.url in the first instance and product.url in the second instance ALREADY contain the path, so those double whatever should've been there. I've just removed the request.path in both instances and tested it. I'm going with that for now.
This is an accepted solution.
autoBlogger: Seamlessly scheduled, fully automated, AI-powered, and SEO-optimised blogging with FAQs, table of contents and other features! Start your 14-day free trial today!
autoSchema: Fully automated and continuously updated Google structured data, including duplicate data removal. Simple to install – try it now!
Aha.. yes, thank you for that hint. I replaced {{ request.path }} with {{ shop.url }}. It now looks good.
No problem at all! Remember to mark as solved, if we have got this one sorted 🙂
autoBlogger: Seamlessly scheduled, fully automated, AI-powered, and SEO-optimised blogging with FAQs, table of contents and other features! Start your 14-day free trial today!
autoSchema: Fully automated and continuously updated Google structured data, including duplicate data removal. Simple to install – try it now!
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025