Google会抓取HTML5模板标记内的内容吗?

Mat*_*lor 8 seo html5 templates

HTML5模板标签应该是完全惰性的,就好像源中不存在内容,但是Google抓取然后索引网页的情况呢?

有没有人能够以某种方式证明Google索引或不对模板标记内的内容编制索引?模板标签很棒,但如果它们对SEO产生负面影响,我不想使用它们

小智 6

我今天经历了一些事情,可以肯定它确实会影响SEO。

我刚刚收到一个警告从谷歌搜索控制台约增加404错误,并在错误几乎所有网址都以这种形式:/some-path/some-page/$%7Bconsent.infoURL%7D

URL解码后,我们可以看到这${consent.infoURL}是我在模板标签上使用的一个变量,该href属性是:

<template data-template="cookie-notice">
    `<div data-cookie-notice class="cookie-notice" role="dialog">
    <span class="cookie-notice-caption">${consent.captionText}</span>
    <a class="cookie-notice-link" href="${consent.infoURL}">${consent.linkText}</a>
    <button data-button-consent type="button" class="cookie-notice-button">${consent.buttonText}</a>
    </div>`
</template>
Run Code Online (Sandbox Code Playgroud)

因此,Google Bot实际上遵循template标记中的链接。


jam*_*yle 5

我对此也很好奇,因为我正在考虑使用 <template>标签作为服务器端渲染的一种形式,或者预渲染一些页面准备好后将通过 AJAX/JS 更新的内容。

我检查了谷歌网站管理员工具结构化数据测试器,看看它是否会从放置在标签内的 HTML 标签中读取微数据<template>

谷歌结构化数据模板标签测试

从截图中可以看出,它似乎确实读取了<template>标签内的数据。我不会认为这是一个经过验证的答案,但它确实表明解析器(至少在涉及 HTML 微数据时)不会忽略<template>标签内的内容。