• Priority: 0
  • Status: Closed
  • Theme: Alysum
  • Assigned To: Fred
  • Private: No
  • Open Date: 12.05.20, 20:35
  • Opened by: Marco Montanari
  • Closed by: Anonymous Submitter
  • Closed on:
  • Reason: Not a bug

Ticket #17845 - [ SUGGESTION] Improve schema.org product to validate

on each product page there is a

<script type="application/ld+json">

the description field used is not fault tallerant.

the rule to make the schema works is:

1) if the Summary field is empty use Description field of product

Summary is usually a short description suitable for schema.org description, but must be cleanedup from HTML parts.
Only in case is empty you can use a html cleaned up version of the Description (long description field usually full of html tags)

Comments

Anonymous Submitter 13 May 2020, 07:37

Hi Marco.
Can you contact me in PV please ?
I am agree with you and want to talk about it.

Fred 13 May 2020, 10:16

Do you mean this line?

<meta property="og:description" content="{$page.meta.description}">
Marco Montanari 13 May 2020, 10:20

yes that is the schema.org description line.
Must be a fall back using first the summary description if available then a product description or if not a meta description (seo field)

Fred 13 May 2020, 18:57

Done

<meta property="og:description" content="{if !empty($product.description_short)}{$product.description_short}{else}{$page.meta.description}{/if}">
Marco Montanari 14 May 2020, 11:49

Hi Fred,

the right sequence must be:

$product.description_short
or
$product.description
or
$page.meta.description

Please cleanup from HTML the $product.description_short and $product.description to avoid HTML inside these fields for schema.org

like:

$product.description_short|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'

and for meta:

$page.meta.description|strip_tags:'UTF-8'

Inside the schema, and in generally in all title, alt and so on tags, all text must be escaped to reach the validation and erach AMP/HTML validation too

Fred 14 May 2020, 12:25

Done

{if !empty($product.description_short)}
  {assign var="ogdesc" value=$product.description_short|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}
{elseif !empty($product.description)}
  {assign var="ogdesc" value=$product.description|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}
{else}
  {assign var="ogdesc" value=$page.meta.description|strip_tags:'UTF-8'}
{/if}

<meta property="og:description" content="{$ogdesc}">
Marco Montanari 14 May 2020, 12:46

Fred is better to remove/strip html in case of :

<br>

or

<p></p>
{if !empty($product.description_short|strip_tags:'UTF-8')}
  {assign var="ogdesc" value=$product.description_short|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}
{elseif !empty($product.description|strip_tags:'UTF-8')}
  {assign var="ogdesc" value=$product.description|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}
{else}
  {assign var="ogdesc" value=$page.meta.description|escape:'htmlall':'UTF-8'}
{/if}

<meta property="og:description" content="{$ogdesc}">

$page.meta.description cannot contain HTML tags so you need only to escaping the variable.

This patch is already applied in my installation?

thanks

Fred 14 May 2020, 13:14

Thank you for suggestion