【问题标题】:Why Google suggesting to use META TAGS in Body?为什么 Google 建议在 Body 中使用 META TAGS?
【发布时间】:2021-12-12 19:54:12
【问题描述】:

我正在为 Google 的附加链接搜索框搜索微数据。所以我在谷歌网站上找到了一个页面。

这是微数据代码 -

<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

【问题讨论】:

  • 请注意,<meta><input> 标记不使用也不需要结束斜线,并且在任何 HTML 规范中都没有。

标签: html seo schema google-search microdata


【解决方案1】:

文档正文中的&lt;div&gt;&lt;form&gt; 标记中允许使用一些元标记。见&lt;meta&gt;: The metadata element - HTML: HyperText Markup Language | MDN 上面写着:

允许的父母

  • ...
  • &lt;meta itemprop&gt;:任何接受元数据内容的元素或flow content

从关于流内容的页面来看,允许流内容的元素包括&lt;body&gt;中使用的&lt;div&gt;&lt;form&gt;

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

【讨论】:

  • 那么元标记不会暴力 html5 标记?,正如我在某处读到的那样
  • 请告诉我在元目标标签的内容中输入什么。 如果我们可以通过example.com/?s=the%20query 在我们的网站上搜索
  • 输入标签的name属性是's'
  • HTML 规范允许在正文中使用 Itemprop 元标记,因此将它们放在那里不会违反规范。
  • 如果搜索查询参数被命名为s,则应该在Google 示例中q 所在的位置。
猜你喜欢
  • 2021-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-18
  • 2011-08-03
  • 2012-04-21
相关资源
最近更新 更多