Best practices for adding semantics to a website

て烟熏妆下的殇ゞ 提交于 2019-11-26 09:00:29
unor

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>

I suggest that you first look at the schema.org straightforward documentation. This vocabulary is very comprehensive for your concerns and supported by the major search engines.

Here is a snippet example for you to get started, you can include this straight in an HTML page. When you speak about the performance of the play on a page you could use:

<div itemscope itemtype="http://schema.org/TheaterEvent">
  <h1 itemprop="name">Romeo and Juliet</h1>
  <span itemprop="location">Council Bluffs, IA, US</span>
  <meta itemprop="startDate" content="2011-05-23">May 23
  <a href="/offers.html" itemprop="offers">Buy tickets</a>
</div>

On your contact page you could include:

<div itemscope itemtype="http://schema.org/TheaterGroup">
  <span itemprop="name">Magma</span>
  Tel:<span itemprop="telephone">( 33 1) 42 68 53 00 </span>
</div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!