Mobile app version of vmapp.org
Login or Join
Becky754

: How do I get the Structured Data Testing Tool to ignore template elements? I’m using Web Components to build a site, and one of the biggest features is my use of the <template> element.

@Becky754

Posted in: #GoogleRichSnippetsTool #Html #Microdata #Template #WebComponents

I’m using Web Components to build a site, and one of the biggest features is my use of the <template> element. Here’s an example:

<ul>
<template>
<li>
<div class="c-ArticleTeaser" itemscope="" itemtype="http://schema.org/NewsArticle">
<img class="c-ArticleTeaser__Img" src="{{ database__image }}" alt="" itemprop="image thumbnailUrl"/>
<p class="c-ArticleTeaser__Hn">
<a class="c-ArticleTeaser__Link" href="{{ database__url }}" itemprop="url mainEntityOfPage">
<cite itemprop="headline">{{ database__title }}</cite>
</a>
</p>
<p class="c-ArticleTeaser__Date">
<time datetime="{{ database__datetime }}" itemprop="datePublished">{{ database__datetime_formatted }}</time>
</p>
</div>
</li>
</template>
</ul>


(A list containing a <template>, used for dynamically marking up article teaser items, each containing a headline, image, and timestamp.)

My front-end script clones the <template> content, fills in the missing data from a database, and then appends the newly-created <li> element to the end of the <ul>. The result is a <ul> with one <template> child followed by a bunch of <li> children.

When I run my markup through the Structured Data Testing Tool, it parses the “filled-in” articles correctly, but it also reads the dummy article in the <template> element. This throws a bunch of errors, such as:


Cannot understand the value {{ database__datetime }}


I can’t remove the template element from the DOM, in case it needs to be dynamically used again after page load.

Two questions:


How do I get the tool (and Google) to ignore <template> elements?
If I can’t, will these errors penalize my site?

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Becky754

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme