Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
294 views
in Technique[技术] by (71.8m points)

seo - Concepts for RDFa DRY references

I started digging into RDFa recently and try to spice my website with semantic information. The site offers services, events, a blog and may offer products in future. Happily schema.org has coarse but adequate categories for it all. But now it comes to practical questions.

All the examples have all information on a single page, which seems pretty academic to me. E.g. on my landing page is a list with upcoming events. Events have a location property. My events run at 2 different locations. I could paste the location information for each entry in and inflate my html. I'd rather link to pages, which describe the locations and hold full details. Not sure, whether this is what sameAs is for. But even then, how would it know which RDFa information on the target URL should be used as the appropriate vCard?

Similarly, my landing page has only partial company information visible. I could add a lot of <meta>, but again a reference to the contact page would be nice.

I just don't want to believe that this aspect slipped the RDF creators. Are there any best practices for redundancy reduction?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

URIs! (or IRIs, e.g., in RDFa 1.1)

That’s one of the primary qualities of RDF, and it makes Linked Data possible, as coined by Tim Berners-Lee (emphasis mine):

The Semantic Web isn't just about putting data on the web. It is about making links, so that a person or machine can explore the web of data.

Like the web of hypertext, the web of data is constructed with documents on the web. However, unlike the web of hypertext, where links are relationships anchors in hypertext documents written in HTML, for data they links between arbitrary things described by RDF

From my answer to a question about the Semantic Web:

Use RDF (in the form of a serialization format of your choice) and define URIs for your entities so that you and other people can make statements about them.

So give all your "entities" an URI and use it as subject resp. object in RDF triples. Note that you may not want to use the same URI which your web pages have, as it would make it hard to distinguish between data about the web page and data about the thing represented by the web page (see my answer describing this in more detail).

So let’s say your website has these two pages:

  • http://example.com/event/42 (about the event 42, i.e., the HTML page)
  • http://example.com/location/51 (about the location 51, i.e., the HTML page)

Using the hash URI method, you could mint these URIs:

  • http://example.com/event/42#it (the event 42, i.e., the real thing)
  • http://example.com/location/51#it (the location 51, i.e., the real thing)

Now when you want to use the Schema.org vocabulary to give information about your event, you may use resource to give its URI:

<!-- on http://example.com/event/42 -->
<article resource="#it" typeof="schema:Event">
  <h1 property="schema:name">Event 42</h1>
</article>

And when you want to specify the event’s location (using Place), you could use the URI of the location:

<!-- on http://example.com/event/42 -->
<article about="#it" typeof="schema:Event">
  <h1 property="schema:name">Event 42</h1>
  <a property="schema:location" typeof="schema:Place" href="/location/51#it">Location 51</a>
</article>

And on the location page you might have something like:

<!-- on http://example.com/location/51 -->
<article about="#it" typeof="schema:Place">
  <h1 property="schema:name">Location 51</h1>
  <a property="schema:event" typeof="schema:Event" href="/event/42#it">Event 42</a>
</article>

Aggregating this data, you’ll have these triples (in Turtle):

@prefix schema: <http://schema.org/> .

<http://example.com/location/51#it> a schema:Place .
<http://example.com/location/51#it> schema:event <http://example.com/event/42#it> .
<http://example.com/location/51#it> schema:name "Location 51" .

<http://example.com/event/42#it> a schema:Event .
<http://example.com/event/42#it> schema:location <http://example.com/location/51#it> .
<http://example.com/event/42#it> schema:name "Event 42" .

EDIT: I’m not sure (and I hope it’s not the case), but maybe Schema.org expects a blank node with a url (or sameAs?) property instead, e.g.:

<article about="#it" typeof="schema:Event">
  <h1 property="schema:name">Event 42</h1>
  <div property="schema:location" typeof="schema:Place">
    <a property="schema:url" href="/location/51#it">Location 51</a>
  </div>
</article>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...