向网站添加语义的最佳实践 [英] Best practices for adding semantics to a website

查看:81
本文介绍了向网站添加语义的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对网站的语义有些困惑.我了解每个URI都应代表一个资源.我假设RDFa在网页内提供的所有信息均描述了该网页URI表示的资源.我的问题是:为网站的子页面提供语义数据的最佳实践是什么.

就我而言,我想使用带有schema.org和opengraph词汇的RDFa为名为magma的剧院集团创建一个网站.假设我有一个欢迎页面(http://magma.com/),一个联系页面(http://magma.com/contact/)和各个播放页面(http://magma.com/play/<playid>/).

现在,我认为欢迎页面和联系页面都代表相同的资源(岩浆),同时提供有关该资源的不同信息.然而,播放页面表示仅碰巧由岩浆执行的播放.还是说播放页面也代表岩浆,但提供了将由该小组执行的有关播放的信息,是更好的说法?我偶然发现的第三个选项是 http://schema.org/WebPage .尤其是像ContactPage这样的子类型似乎很重要.

在实施时,我应该将RDFa放在哪里?

最后:我的选择将如何改变第三方(谷歌,facebook,...)对待网站的方式?

我意识到这个问题有点模糊.为了更具体,我将添加一个示例,您可能会对此感到好奇:

<html vocab="http://schema.org/" typeof="TheaterGroup">
  <head>
    <meta charset="UTF-8"/>
    <title>Magma - Romeo and Juliet</title>

    <!-- magma sematics from a template  file -->
    <meta property="name" content="Magma"/>
    <meta property="logo" content="/static/logo.png"/>
    <link rel="home" property="url" content="http://magma.com/"/>
  </head>

  <body>
    <h1>Romeo and Juliet</h1>

    <!-- semantics of the play -->
    <div typeof="CreativeWork" name="Romeo and Juliet">
      ...
    </div>

    <h2>Shows</h2>

    <!-- samantics of magma events -->
    <ul property="events">
      <li typeof="Event"><time property="startDate">...</time></li>
      ...
    </ul>
  </body>
</html>

解决方案

我了解每个URI都应代表一个资源.我假设RDFa在网页内提供的所有信息均描述了该网页URI所代表的资源.

嗯,HTTP URI可以识别页面本身或该页面所涉及的内容.您不能仅仅通过查看URI就能识别出页面或事物.

示例(采用Turtle语法):

 <http://en.wikipedia.org/wiki/The_Lord_of_the_Rings> ex:author "John Doe"
 

可以表示具有URI http://en.wikipedia.org/wiki/The_Lord_of_the_Rings的HTML页面是由"John Doe"创作的.或可能意味着该HTML页面(→小说)所描述的内容是由"John Doe"创作的.当然,这是一个重要的区别.

有多种方法可以区分URI表示什么,对此存在一些争议.关于此问题的讨论称为 httpRange-14问题.例如,请参阅Wikipedia文章网络资源.

一种方法是使用哈希URI (另请参阅此答案).例如:http://magma.com/play/42可以识别有关该剧的页面http://magma.com/play/42#play可以识别该剧的页面.

另一种方法是使用 HTTP状态码303 .代码200提供有关事物的页面表示,代码303 See Other提供标识事物的附加URI. DBpedia使用此方法:

请参见在303和哈希之间选择.

现在,使用RDFa时,您可以对页面本身以及该页面代表的内容进行声明.只需使用相应的URI作为主题即可(例如,通过使用 resource属性).

因此,假设http://magma.com/#magma代表剧院组.现在,您可以在每个 页面(/contact,/play/,...)上使用此URI来对组的各个内容进行 about 声明.来指代这个小组.

 <div resource="http://magma.com/#magma">
  <span property="ex:name">Magma</span>
</div>

<div resource="http://magma.com/">
  <span property="ex:name">Website of Magma</span>
</div>
 

I am a bit confused about the semantics of websites. I understand that every URI should represent a ressource. I assume that all information provided by RDFa inside a webpage describes the ressource represented by the URI of that webpage. My question is: What are best practices for providing semantic data for subpages of a website.

In my case I want to create a website for a theater group called magma using RDFa with schema.org and opengraph vocabularies. Let's say I have the welcome page (http://magma.com/), a contact page (http://magma.com/contact/) and pages for individual plays (http://magma.com/play/<playid>/).

Now I would think that both the welcome page and the contact page represent the same ressource (magma) while providing different information about that ressource. The play pages however represent plays that only happen to be performed by magma. Or is it better to say that the play pages also represent magma but providing information about plays which will be performed by that group? The third option I stumbled upon is http://schema.org/WebPage. Especially subtypes like ContactPage seems to be relevant.

When it comes to implementation, where do I put the RDFa?

And finally: How will my choice change the way the website is treated by 3rd parties (google, facebook, ...)?

I realize this question is a bit blurry. To make it more concrete I will add an example that you might critizise:

<html vocab="http://schema.org/" typeof="TheaterGroup">
  <head>
    <meta charset="UTF-8"/>
    <title>Magma - Romeo and Juliet</title>

    <!-- magma sematics from a template  file -->
    <meta property="name" content="Magma"/>
    <meta property="logo" content="/static/logo.png"/>
    <link rel="home" property="url" content="http://magma.com/"/>
  </head>

  <body>
    <h1>Romeo and Juliet</h1>

    <!-- semantics of the play -->
    <div typeof="CreativeWork" name="Romeo and Juliet">
      ...
    </div>

    <h2>Shows</h2>

    <!-- samantics of magma events -->
    <ul property="events">
      <li typeof="Event"><time property="startDate">...</time></li>
      ...
    </ul>
  </body>
</html>

解决方案

I understand that every URI should represent a ressource. I assume that all information provided by RDFa inside a webpage describes the ressource represented by the URI of that webpage.

Well, a HTTP URI could identify the page itself OR the thing the page is about. You can't tell if an URI identifies the page or the thing by simply looking at it.

Example (in Turtle syntax):

<http://en.wikipedia.org/wiki/The_Lord_of_the_Rings> ex:author "John Doe"

This could mean that the HTML page with the URI http://en.wikipedia.org/wiki/The_Lord_of_the_Rings is authored by "John Doe". Or it could mean that the thing described by that HTML page (→ the novel) is authored by "John Doe". Of course this is an important difference.

There are various ways to differentiate what an URI represents, and there is some dispute about it. The discussion around this is known as httpRange-14 issue. See for example the Wikipedia article Web resource.

One way is using hash URIs (see also this answer). Example: http://magma.com/play/42 could identify the page about the play, http://magma.com/play/42#play could identify the play.

Another way is using HTTP status code 303. The code 200 gives the representation of the page about the thing, the code 303 See Other gives an additional URI identifying the thing. This method is used by DBpedia:

See Choosing between 303 and Hash.

Now, when using RDFa, you can make statements about both, the page itself and the thing represented by the page. Just use the corresponding URI as subject (e.g., by using the resource attribute).

So let's say http://magma.com/#magma represents the theater group. Now you could use this URI on every page (/contact, /play/, …) to make statements about the group resp. to refer to the group.

<div resource="http://magma.com/#magma">
  <span property="ex:name">Magma</span>
</div>

<div resource="http://magma.com/">
  <span property="ex:name">Website of Magma</span>
</div>

这篇关于向网站添加语义的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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