Schema - Bsale-IO/template-docs GitHub Wiki
Home > Componente > Componentes SEO > Schema
Este componente permite que diferentes plataformas (google, facebook,etc...) puedan tomar la información de tu sitio web y mostrar información enriquecida de las paginas de tu sitios, debe ir dentro del Componente Head
Este componente debe estar dentro del Componente Head, su tu template no lo tiene dentro del Componente Head puede generar problemas con algunas extensiones
Para poder revisar que los datos estén correctamente cargados puedes testear acá
- google rich data para cualquier pagina de tu sitio.
- Facebook microdata Sólo para la página de producto
{% comment %} versión DICIEMBRE 2024 {%endcomment%}
<script>
{{variant | json_encode}}
</script>
{% capture json %}
<script type="application/ld+json" data-schema="WebSite">
{
"@context": "http://schema.org/",
"@type": "WebSite",
"url": "{{canonical_url}}",
"potentialAction": {
"@type": "SearchAction",
"target": "{{canonical_url}}?search_text={search_term_string}",
"query-input": "required name=search_term_string"
}
}
</script>
<script type="application/ld+json" data-schema="Store">
{
"@context": "http://schema.org/",
"@type": "Store",
"name": "{{site.name | replace: '"','"'}}",
"description": "{{site.description | replace: '"','"'}}.",
"telephone": [{% for tel in site.contact_numbers %}"{{tel}}"{% unless forloop.last%},{%endunless%}{%endfor%}],
"priceRange": "$$",
"image": "{{ site.logo| image_url: 'O' }}",
"address": {
"@type": "PostalAddress",
"addressCountry": "{% if site.currency.isoCode == "CLP" %}CL{%else%}PE{%endif%}",
"streetAddress": "{{site.shop_address | replace: '"','"'}}"
}
}
</script>
<script type="application/ld+json" data-schema="Organization">
{
"@context": "http://schema.org/",
"@type": "Organization",
"url": "{{site.url}}",
"logo": "{{site.logo}}",
{% if site.social_networks.size > 0 %}{% capture sameAs %}[{% for x in site.social_networks %}{% assign name = x.title | downcase %}{%if name == "whatsapp" %}{%continue%}{%else%}"{{x.value|strip|downcase}}",{%endif%}{%endfor%}]{%endcapture%}
"sameAs": {{sameAs|strip|replace: ",]", "]"}},
{% endif %}
"contactPoint": [{
"@type": "ContactPoint",
"telephone": "{% for tel in site.contact_numbers %}{%if forloop.first%}{{tel}}{%endif%}{%endfor%}",
"contactType": "customer service"
}]
}
</script>
{%if current_url contains '/product/' %}
{% for var in variant %}
<script type="application/ld+json" data-schema="Product">
{
{% assign _name = product.title | append:" "| append: var.title | replace: '"','"' %}
{% assign _brand = brand.br_name | replace: '"','"' %}
"@context": "http://schema.org/",
"@type": "Product",
"@id": "{{product.id}}_{{var.id}}",
{% if brand.br_name.size > 0 %}"brand": {"@type": "Brand", "name": "{{_brand}}"},{% endif %}
"name": "{{_name}}",
"description": "{% if product.description.size > 0 %}{{product.description | strip_html | replace: '"','"'}}{%else%}{{_name}} {{_brand}} {%endif%}",
"url": "{{canonical_url}}",
"sku": "{{var.sku}}",
"gtin": "{{var.gtin}}",
"image":[{% for i in images %}"{{i.href}}"{% unless forloop.last %},{% endunless %}{%endfor%}],
"offers":{
"@type": "Offer",
"url": "{{canonical_url}}",
"itemCondition": "https://schema.org/NewCondition",
"availability" : {% if var.allowNegativeStock > 0 or var.unlimitedStock > 0 %}"https://schema.org/InStock"{% else %} {% assign st = var.id | get_stock_variant %}{% if st > 0 %}"https://schema.org/InStock"{%else%}"https://schema.org/OutOfStock"{%endif%}{%endif%},
"price": {{ var.finalPrice | round: site.currency.roundDecimals }},
"priceCurrency": "{{site.currency.isoCode}}",
"priceValidUntil": "{{'today' | date: '%Y%m%d' | plus: 1}}",
"priceSpecification": [{
"@type": "PriceSpecification",
"priceCurrency": "{{site.currency.isoCode}}",
"price": {{ var.finalPrice | round: site.currency.roundDecimals }},
"valueAddedTaxIncluded": "http://schema.org/True"
}],
"seller": {"@type": "Organization","name": "{{ site.name | replace: '"','"' }}","url": "{{canonical_url}}"}
},
"additionalProperty": [{
"@type": "PropertyValue",
"propertyID": "item_group_id",
"value": "{{product.id}}"
}]
}
</script>
{% endfor %}
{% if product.brand or product.collections.size > 0 %}
{% if product.brand.size > 0 %}
<script type="application/ld+json" data-schema="BreadcrumbList">
{
"@context": "http://schema.org/",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "{{ product.brand.name | replace: '"','"'}}",
"item": "{{canonical_url}}"
},{
"@type": "ListItem",
"position": 2,
"name": "{{title | replace: '"','"'}}"
}
]
}
</script>
{%endif%}
{% for collection in product.collections %}
<script type="application/ld+json" data-schema="BreadcrumbList">
{
"@context": "http://schema.org/",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "{{ collection.name | replace: '"','"'}}",
"item": "{{canonical_url}}"
},{
"@type": "ListItem",
"position": 2,
"name": "{{title | replace: '"','"'}}"
}
]
}
</script>
{% endfor%}
{% else %}
<script type="application/ld+json" data-schema="BreadcrumbList">
{
"@context": "http://schema.org/",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "{{product.title | replace: '"','"'}}"
}
]
}
</script>
{% endif %}
{% elsif current_url contains '/collection/' or current_url contains '/brand/' %}
<script type="application/ld+json" data-schema="itemList">
{
"@context": "http://schema.org/",
"@type": "ItemList",
"name": "{{ title | replace: '"','"'}}",
"itemListElement": [
{% for product in collection %}
{
"@type": "listItem",
"position": "{{forloop.index}}",
"item": {
"@type": "product",
"name": "{{product.title | replace: '"','"'}}",
"url": "{{canonical_url}}#product-{{product.id}}",
"image": "{{product.defaultImage| image_url}}",
"description": "{% if product.description.size > 0 %}{{product.description | strip_html | replace: '"','"'}}{%else%}{{product.title | replace: '"','"'}} {{product.finalPrice | money_filter}} {%endif%}",
{% if product.brand.name.size > 0 %}
"brand": {
"@type": "Brand",
"name": "{{product.brand.name | replace: '"','"'}}"
},
{% endif %}
"offers": {
"@type": "Offer",
"priceCurrency": "{{site.currency.isoCode}}",
"price": "{{ product.finalPrice | round: site.currency.roundDecimals}}",
"priceValidUntil": "{{'today' | date: '%Y%m%d'}}",
"itemCondition": "https://schema.org/NewCondition",
"availability": "https://schema.org/InStock",
"url": "{{canonical_url}}",
"seller": {
"@type": "Organization",
"name": "{{ site.name | replace: '"','"'}}",
"url": "{{canonical_url}}"
}
}
}
}{%unless forloop.last%},{%endunless%}
{% endfor %}
]
}
</script>
<script type="application/ld+json" data-schema="BreadcrumbList">
{
"@context": "http://schema.org/",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"item": "{{canonical_url}}",
"name": "{{title | replace: '"','"'}}"
}
]
}
</script>
{% elsif current_url contains '/article/' %}
<script type="application/ld+json" data-schema="NewsArticle">
{
"@context": "http://schema.org/",
"@type": "NewsArticle",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{canonical_url}}"
},
"headline": "{{article.title | replace: '"','"'}}",
"image": ["{%if article.image %} {{article.image}} {%else%} {{site.logo}} {%endif%}"],
"datePublished": "{{article.created | date: "%Y-%m-%d %H:%M" }}",
"dateModified": "{{article.modify_date | date: "%Y-%m-%d %H:%M"}}",
"author": {
"@type": "Person",
"name": "{{site.name | replace: '"','"'}}"
},
"publisher": {
"@type": "Organization",
"name": "{{site.name | replace: '"','"'}}",
"logo": {
"@type": "ImageObject",
"url": "{{site.logo}}"
}
},
"description": "{{article.content | strip_html | replace: '"','"' | truncate: 100, "..."}}"
}
</script>
<script type="application/ld+json" data-schema="BreadcrumbList">
{
"@context": "http://schema.org/",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"item": "{{canonical_url}}/blog",
"name": "Blog"
},{
"@type": "ListItem",
"position": 2,
"name": "{{title | replace: '"','"'}}"
}
]
}
</script>
{% elsif current_url.size > canonical_url.size and title %}
<script type="application/ld+json" data-schema="BreadcrumbList">
{
"@context": "http://schema.org/",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "{{ title | replace: '"','"'}}"
}
]
}
</script>
{%endif%}
{% endcapture %}
{{json | strip_newlines}}