将schema.org标记添加到网站的标题:如何以及哪个模式? [英] Adding schema.org tags to a site's header: how and which schema?

查看:143
本文介绍了将schema.org标记添加到网站的标题:如何以及哪个模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个提供运输服务的网站,而不是产品(我的意思是我们不销售这个品牌的小部件,这个其他型号......;我们只提供一种运输服务)。我有点不清楚如何将schema.org微数据添加到我的网站,所以我基本上看了瑞安航空正在做(因为我们的产品最类似于他们的产品)并复制了他们的标记(显然将其更改为我们公司的名称)。他们的标记是这样的:

I have a website that provides transportation services, not products (with this I mean that we don't sell widgets of this brand, this other model...; we just provide one kind of transportation service). I'm a bit unclear about how should I add schema.org microdata to my site, so I basically looked at what Ryanair was doing (since our product most resembles theirs) and copied their markup (changing it to our company's name, obviously). Their markup is as such:

<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<meta content="#22356b" name="theme-color"/>
<meta content="Book Cheap Flights direct at the official Ryanair website for Europe's lowest fares. Fully allocated seating and much more now available online" name="description"/>
<meta content="summary" name="twitter:card"/>
<meta content="@ryanair" name="twitter:site"/>
<meta content="Cheap Flights | Cheap Flights to Europe | Ryanair" name="twitter:title"/>
<meta content="Book Cheap Flights direct at the official Ryanair website for Europe's lowest fares. Fully allocated seating and much more now available online" name="twitter:description"/><meta content="@ryanair" name="twitter:creator"/>
<meta content="/static/images/seo/seo-logo-200.png" name="twitter:image:src"/>
<meta content="https://www.ryanair.com" name="twitter:domain"/>

<meta itemtype="http://schema.org/Product" itemscope="itemscope"/>

<meta content="Cheap Flights | Cheap Flights to Europe | Ryanair" property="og:title"/>

<meta content="Cheap Flights | Cheap Flights to Europe | Ryanair" itemprop="headline"/>
<meta content="Book Cheap Flights direct at the official Ryanair website for Europe's lowest fares. Fully allocated seating and much more now available online" property="og:description"/>
<meta content="Book Cheap Flights direct at the official Ryanair website for Europe's lowest fares. Fully allocated seating and much more now available online" itemprop="description"/>
<meta content="http://www.ryanair.com/en/" property="og:url"/>
<meta content="/static/images/seo/seo-logo-200.png" property="og:image"/>
<meta content="/static/images/seo/seo-logo-200.png" itemprop="image"/>
<meta content="article" property="og:type"/>
<meta content="Ryanair" property="og:site_name"/>
<meta content="" property="fb:admins"/><link href="https://plus.google.com/" rel="publisher"/>
<meta content="INDEX,FOLLOW" name="robots"/>
<meta content="NOYDIR" name="Slurp"/>
<meta content="NOODP" name="Robots"/>
<meta content="Copyright Ryanair.com 2014" name="dcterms.rightsHolder"/>

然而,Google网站管理员工具在以下行中显示错误:

And yet, Google Webmaster Tools shows me an error in the following line:

<meta itemtype="http://schema.org/Product" itemscope="itemscope" />

说它需要名称属性。

我该如何添加?我看过的所有示例都是针对您有多个产品并需要标记其中每个产品的情况。此外,我看到的所有示例都是在网页的正文中添加标记,而不是在标题中添加标记。哪一个是正确的?

How should I add this? All the examples I've looked at are for situations where you have multiple products and need to mark up each one of them. Also, all the examples I've seen are for adding markup in the webpage's body, not in the header. Which one is correct?

推荐答案

更新:以下答案并不完全正确。它 可以表达 head 元素中的每个微数据, head <上不需要父项/ code>或 html 元素。有关示例,请参阅我对相关Schema.org问题的评论,它使用样式元素来创建顶级项目:

Update: The below answer is not fully correct. It is possible to express every Microdata within the head element, there is no need for a parent item on the head or html element. For an example, see this snippet from my comment on a related Schema.org issue, which uses a style element to create a top-level-item:

<head>
  <style itemscope itemtype="http://schema.org/Thing" itemref="i1a i1b"></style>
  <meta id="i1a" itemprop="name" content="Top-level item 1" />
  <meta id="i1b" content="" itemprop="image" itemscope itemtype="http://schema.org/ImageObject" itemref="i1b-1a i1b-1b" />
  <meta id="i1b-1a" itemprop="name" content="Nested item 1" />
  <link id="i1b-1b" itemprop="contentUrl" href="image.png" />
</head>

这不是一个好习惯,因为所有需要的 itemref而变得混乱 / id 值,但它有效。

Not a good practice, and it becomes chaotic because of all the needed itemref/id values, but it’s valid.

从您在问题中包含的代码段中,只有这些元素包含微数据:

From the snippet you included in your question, only these elements contain Microdata:


<meta itemtype="http://schema.org/Product" itemscope="itemscope"/>
<meta content="Cheap Flights | Cheap Flights to Europe | Ryanair" itemprop="headline"/>
<meta content="Book Cheap Flights direct at the official Ryanair website for Europe's lowest fares. Fully allocated seating and much more now available online" itemprop="description"/>
<meta content="/static/images/seo/seo-logo-200.png" itemprop="image"/>


此代码无效,无法执行他们可能想要的操作实现。

This code is not valid, and not doing what they probably want to achieve.

如果你只想在 head 元素中提供微数据(这没有多大意义,但是让我们假装你需要一个可以有子元素的元素。否则,您无法创建顶级微数据项。

If you want to provide Microdata only in the head element (which wouldn’t make much sense, but let’s pretend) you need an element that can have child elements. Otherwise you can’t create a top-level Microdata item.

唯一的候选者是 head 元素本身,所以你只能提供一个 head 中的项目,它可能没有将另一个项目作为值的属性。对于属性,您将使用 link 元素(如果值是URI)和元素(如果值不是一个URI)。

The only candidate is the head element itself, so you could only provide one item in the head, and it could have no properties that take another item as value. For properties you would use link elements (if the value is a URI) and meta elements (if the value is not a URI).

所以它必须是(省略标题属性,因为它不允许产品):

So it would have to be (omitting the headline property, because it’s not allowed for Product):

<head itemscope itemtype="http://schema.org/Product">
  <meta content="…" itemprop="description"/>
  <link href="…" itemprop="image"/>
</head>

这是非常有限的。所以,如果你想使用Microdata(或RDFa),你很可能想要使用整个文件( html head body )。使用Microdata / RDFa的重点是利用您现有的内容,而不必复制它。如果您不想注释现有内容,可以使用JSON-LD并简单地在脚本元素中提供所有属性,例如,在<$ c中$ c> head

That’s pretty limited. So, if you want to use Microdata (or RDFa), you most likely want to make use of the whole document (html, head and body). The whole point of using Microdata/RDFa is to make use of your existing content, without having to duplicate it. If you don’t want to "annotate" your existing content, you could use JSON-LD and simply provide all properties in a script element, e.g., in the head.

关于缺少的名称属性:如果Google的结构化数据测试工具说缺少一个属性,这只是意味着如果遗漏了谷歌,谷歌就不会某些事情。如果没有它,这并不意味着代码无效,因为Schema.org没有必需的属性。

About the missing name property: If Google’s Structured Data Testing Tool says that a property is missing, it just means that Google won’t do something with your markup if it’s missing. It does not mean that the code would be invalid without it, as Schema.org has no required properties.

这篇关于将schema.org标记添加到网站的标题:如何以及哪个模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆