schema.org 和在线词典 [英] schema.org and an online dictionary

查看:52
本文介绍了schema.org 和在线词典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 schema.org 中的内容时遇到问题.我正在制作一个类似于 urbandictionary.com 的网站.用户是词典的贡献者.此外,字典可能包括诸如2012 年伦敦奥运会"、麻省理工学院宿舍"等短语.随便.所以我想向网站添加架构.应该对单词/短语和用户描述进行架构命名吗?

http://schema.org/docs/full.html

示例页面的布局:

Gmail

  1. Google 的电子邮件服务 -user63
  2. 防止垃圾邮件方面的最佳电子邮件服务 -user21
  3. Gmail 支持 IMAP、POP3、SMTPi OAUTH、FRD、双向安全登录-userMew

Edit2:另一个示例页面的部署:

蝙蝠侠 5

  1. 即将上映的蝙蝠侠电影,贾斯汀·比伯将在其中扮演小丑 -user43,2015 年 5 月
  2. 开幕是一场灾难;比伯滑上楼梯,然后被抬到医院 -user22,2015 年 12 月
  3. 这部电影是一场灾难,质量很差的电影 -userKitten,2016 年 3 月

解决方案

一般

schema.org 上的文档中有一个入门页面.当您正在构建字典时,您可能会在其中包含有关电影的条目(他们正在使用的示例).标记可能如下所示:

<h1 itemprop="name">头像</h1><span>导演:<span itemprop="director">James Cameron</span></span><span itemprop="genre">科幻小说</span><a href="../movies/avatar-theatrical-trailer.html" itemprop="trailer">预告片</a>

这要求您知道您的数据输入当然是一部电影.如果您不知道,您可以使用 itemtype Article(甚至 Thing) 和全局属性 namedescription.

还有关于格式的附加信息,例如日期以及如何使用 meta 标签并设置content属性:<meta itemprop="bestRating" content="5"/>.

您始终可以通过指定属性 additionalType 为一个项目赋予多种类型.您甚至可以扩展架构.但是你应该谨慎使用它们,因为它们不被搜索引擎识别,但将来可能会被使用:

<块引用>

如果模式获得采用并证明对搜索应用程序有用,搜索引擎可能会开始使用这些数据.

一般来说,所有这些标记都是可选的,所以请尽可能多地标记,但只标记那些有意义的部分.来自 schema.org 常见问题:

<块引用>

仅标记项目的某些属性是可以的 - 标记不是全有或全无的选择.

标记验证

为了测试您的标记,Google 提供了一个丰富的代码段测试工具.您可以将您的 HTML 粘贴到那里,然后查看 Google 从中提取的内容.对于上面的例子,这是结果:

项目类型:http://schema.org/movie姓名 = 头像导演 = 詹姆斯卡梅隆体裁=科幻小说预告片文字 = 预告片href = http://www.example.com/movies/avatar-theatrical-trailer.html

在您的页面上

由于您页面上的信息是用户生成的,您可以让用户从更高级别的 schema.org 类型(电影Place(麻省理工学院宿舍)、SportsEvent(2012 年伦敦奥运会)等)并回退到 Thing.然后在与这些类​​型的属性匹配的表单元素中获取数据.保存数据并在构建词典页面时对其进行评估.然后由 Google(和其他人)抓取并用于编制索引.

对于您提供的 Gmail 示例,标记可以简单地如下所示(将其复制并粘贴到 测试工具以查看Google是否理解嵌套):

<h1 itemprop="name">Gmail</h1><div itemprop="comment" itemscope itemtype="http://www.schema.org/Comment"><span itemprop="comment">Google 的电子邮件服务</span><span itemprop="author">user63</span>

<div itemprop="comment" itemscope itemtype="http://www.schema.org/Comment"><span itemprop="comment">防止垃圾邮件方面的最佳电子邮件服务</span><span itemprop="author">user21</span>

<div itemprop="comment" itemscope itemtype="http://www.schema.org/Comment"><span itemprop="comment">Gmail支持IMAP、POP3、SMTPi OAUTH、FRD、双向安全登录</span><span itemprop="author">userMew</span>

附加信息

有关详情,请参阅 Google schema.org 常见问题解答.另请参阅都柏林核心元数据启动 (DCMI)(维基百科)作为语义标记数据的替代方法.他们还有一个wiki页面,用于在schema.org和DC之间进行映射.>

I'm having trouble about what to use from schema.org. I'm making a web site kinda similar to urbandictionary.com. Users are the contributors of the dictionary. Also the dictionary may include phrases like "2012 London Olympics", "MIT Dorms" etc. Whatever. So I want to add schema to the website. What should be schema-named the words/phrases and the users' descriptions?

http://schema.org/docs/full.html

Edit: layout of a sample page:

Gmail

  1. Google's email service -user63
  2. best email service in terms of spam prevention -user21
  3. Gmail has a support of IMAP, POP3, SMTPi OAUTH, FRD, two-way secure login -userMew

Edit2: loyout of another sample page:

Batman 5

  1. Upcoming movie of Batman, where Justien Bieber is going to play Joker -user43, May 2015
  2. The opening was a disaster; Bieber slipped to the stairs and then was carried to a hospital -user22, December 2015
  3. This movie was a disaster, a very poor quality movie -userKitten, March 2016

解决方案

General

There is a getting started page in the documentation on schema.org. As you are building a dictionary, you might have an entry about a movie there (the example they are using). The markup could look like this:

<div itemscope itemtype ="http://schema.org/Movie">
  <h1 itemprop="name">Avatar</h1>
  <span>Director: <span itemprop="director">James Cameron</span></span>
  <span itemprop="genre">Science fiction</span>
  <a href="../movies/avatar-theatrical-trailer.html" itemprop="trailer">Trailer</a>
</div>

This requires that you know that your data entry is a movie of course. If you do not know that, you could use the itemtype Article (or even Thing) and the global properties name and description.

There is also additional information about the format of e.g. dates and how to integrate invisible data using the meta tag and setting a content attribute: <meta itemprop="bestRating" content="5" />.

You can always give multiple types to an item by specifying the property additionalType. You can even extend the schema. But you should use them carefully as they are not recognized by search engines, but might get used in the future:

If the schema gains adoption and proves useful to search applications, search engines may start using this data.

In general, all this markup is optional, so feel free to mark up as much as possible, but only those parts that make sense. From the schema.org FAQ:

It is fine to mark up only some properties of an item - markup is not an all-or-nothing choice.

Markup validation

To test your markup, Google provides a Rich Snippets Testing Tool. You can paste your HTML there and see what Google extracts from it. For the above example, this is the result:

Item
    Type: http://schema.org/movie
    name = Avatar
    director = James Cameron
    genre = Science fiction
    trailer
    text = Trailer
    href = http://www.example.com/movies/avatar-theatrical-trailer.html

On your page

As the information on your page is user-generated, you could let the users choose from the higher level schema.org types (Movie, Place (MIT Dorms), SportsEvent (2012 London Olympics) etc.) and fallback to Thing. Then get the data in form elements matching the properties of those types. Save the data and evaluate it when you build your dictionary pages. It is then crawled by Google (and others) and used for indexing.

For the Gmail example you gave, the markup could simply look like this (copy and paste it into the testing tool to see that Google understands the nesting):

<div itemscope itemtype ="http://www.schema.org/SoftwareApplication">
  <h1 itemprop="name">Gmail</h1>
  <div itemprop="comment" itemscope itemtype="http://www.schema.org/Comment">
    <span itemprop="comment">Google's email service</span>
    <span itemprop="author">user63</span>
  </div>
  <div itemprop="comment" itemscope itemtype="http://www.schema.org/Comment">
    <span itemprop="comment">best email service in terms of spam prevention</span>
    <span itemprop="author">user21</span>
  </div>
  <div itemprop="comment" itemscope itemtype="http://www.schema.org/Comment">
    <span itemprop="comment">Gmail has a support of IMAP, POP3, SMTPi OAUTH, FRD, two-way secure login</span>
    <span itemprop="author">userMew</span>
  </div>
</div>

Additional information

For more information see the Google schema.org FAQs. Also see the Dublin Core Metadata Initiatice (DCMI) (Wikipedia) as an alternative way to semantically markup your data. They also have a wiki page for mapping between schema.org and DC.

这篇关于schema.org 和在线词典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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