Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates Dawn to use the new structured_data filter #3380

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 5 additions & 35 deletions sections/main-article.liquid
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the property-based SEO from this file. Google interprets this as a duplicate item when present along with ld+json: https://search.google.com/test/rich-results/result?id=6ClESn2Nb85_l_LNc1XbVA

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ 'section-blog-post.css' | asset_url | stylesheet_tag }}

<article class="article-template" itemscope itemtype="http://schema.org/BlogPosting">
<article class="article-template">
{%- for block in section.blocks -%}
{%- case block.type -%}
{%- when '@app' -%}
Expand All @@ -15,7 +15,6 @@
>
<div
class="article-template__hero-{{ block.settings.image_height }} media"
itemprop="image"
{% if block.settings.image_height == 'adapt' and article.image %}
style="padding-bottom: {{ 1 | divided_by: article.image.aspect_ratio | times: 100 }}%;"
{% endif %}
Expand Down Expand Up @@ -49,26 +48,24 @@
>
<h1
class="article-template__title"
itemprop="headline"
>
{{ article.title | escape }}
</h1>
{%- if block.settings.blog_show_date -%}
<span class="circle-divider caption-with-letter-spacing" itemprop="dateCreated pubdate datePublished">
<span class="circle-divider caption-with-letter-spacing">
{{- article.published_at | time_tag: format: 'date' -}}
</span>
{%- endif -%}
{%- if block.settings.blog_show_author -%}
<span class="caption-with-letter-spacing" itemprop="author" itemscope itemtype="http://schema.org/Person">
<span itemprop="name">{{ article.author }}</span>
<span class="caption-with-letter-spacing">
<span>{{ article.author }}</span>
</span>
{%- endif -%}
</header>

{%- when 'content' -%}
<div
class="article-template__content page-width page-width--narrow rte{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}"
itemprop="articleBody"
{{ block.shopify_attributes }}
>
{{ article.content }}
Expand Down Expand Up @@ -278,34 +275,7 @@
</article>

<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Article",
"articleBody": {{ article.content | strip_html | json }},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": {{ request.origin | append: page.url | json }}
},
"headline": {{ article.title | json }},
{% if article.excerpt != blank %}
"description": {{ article.excerpt | strip_html | json }},
{% endif %}
{% if article.image %}
"image": [
{{ article | image_url: width: 1920 | prepend: "https:" | json }}
],
{% endif %}
"datePublished": {{ article.published_at | date: '%Y-%m-%dT%H:%M:%SZ' | json }},
"dateCreated": {{ article.created_at | date: '%Y-%m-%dT%H:%M:%SZ' | json }},
"author": {
"@type": "Person",
"name": {{ article.author | json }}
},
"publisher": {
"@type": "Organization",
"name": {{ shop.name | json }}
}
}
{{ article | structured_data }}
</script>

{% schema %}
Expand Down
43 changes: 1 addition & 42 deletions sections/main-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
%}

{%- when 'variant_picker' -%}
{% render 'product-variant-picker', product: product, block: block, product_form_id: product_form_id %}

Check warning on line 462 in sections/main-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-product.liquid#L462

[NestedSnippet] Too many nested snippets

Check warning on line 462 in sections/main-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-product.liquid#L462

[NestedSnippet] Too many nested snippets

Check warning on line 462 in sections/main-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-product.liquid#L462

[NestedSnippet] Too many nested snippets
{%- when 'buy_buttons' -%}
{%- render 'buy-buttons',
block: block,
Expand Down Expand Up @@ -704,53 +704,12 @@
if product.selected_or_first_available_variant.featured_media
assign seo_media = product.selected_or_first_available_variant.featured_media
else
assign seo_media = product.featured_media

Check warning on line 707 in sections/main-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/main-product.liquid#L707

[UnusedAssign] `seo_media` is never used
endif
-%}

<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": {{ product.title | json }},
"url": {{ request.origin | append: product.url | json }},
{% if seo_media -%}
"image": [
{{ seo_media | image_url: width: 1920 | prepend: "https:" | json }}
],
{%- endif %}
"description": {{ product.description | strip_html | json }},
{% if product.selected_or_first_available_variant.sku != blank -%}
"sku": {{ product.selected_or_first_available_variant.sku | json }},
{%- endif %}
"brand": {
"@type": "Brand",
"name": {{ product.vendor | json }}
},
"offers": [
{%- for variant in product.variants -%}
{
"@type" : "Offer",
{%- if variant.sku != blank -%}
"sku": {{ variant.sku | json }},
{%- endif -%}
{%- if variant.barcode.size == 12 -%}
"gtin12": {{ variant.barcode }},
{%- endif -%}
{%- if variant.barcode.size == 13 -%}
"gtin13": {{ variant.barcode }},
{%- endif -%}
{%- if variant.barcode.size == 14 -%}
"gtin14": {{ variant.barcode }},
{%- endif -%}
"availability" : "http://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
"price" : {{ variant.price | divided_by: 100.00 | json }},
"priceCurrency" : {{ cart.currency.iso_code | json }},
"url" : {{ request.origin | append: variant.url | json }}
}{% unless forloop.last %},{% endunless %}
{%- endfor -%}
]
}
{{ product | structured_data }}
</script>
</div>
</product-info>
Expand Down
Loading