首页 > 解决方案 > 为什么 Google 建议在 Body 中使用 META TAGS?

问题描述

我正在为 Google 的 Sitelink Searchbox 搜索微数据。所以我在谷歌网站上找到了一个页面。

这是微数据代码 -

<div itemscope itemtype="https://schema.org/WebSite">
  <meta itemprop="url" content="https://www.example.com/"/>
  <form itemprop="potentialAction" itemscope itemtype="https://schema.org/SearchAction">
    <meta itemprop="target" content="https://query.example.com/search?q={search_term_string}"/>
    <input itemprop="query-input" type="text" name="search_term_string" required/>
    <input type="submit"/>
  </form>
</div>

网址 - > https://developers.google.com/search/docs/advanced/structured-data/sitelinks-searchbox

标签: htmlseoschemagoogle-searchmicrodata

解决方案


一些元标记被允许在文档主体内部<div>和标记内部。<form>请参阅<meta>:元数据元素 - HTML:超文本标记语言 | MDN说:

允许的父母

  • ...
  • <meta itemprop>: 任何接受元数据内容或流内容的元素。

<div>在关于流内容的页面中,允许流内容的<form>元素包括<body>.

因此,虽然许多元标记只属于<head>,但当元标记具有时itemprop,它可以进入<body>(或<head>)。


推荐阅读