Saturday, July 10, 2010

Using Open Graph

The Open Graph Protocol is a reasonable new ad-hoc standard for adding semantic content to web sites. Open Graph got a large boost when Facebook starting using it to encourage easy linking of preferences, etc. to better model users to increase advertising revenues (documentation). Freebase also has an Open Graph interface. For example, you can look me up on Freebase using (leave off the "?html=1" to get a JSON response):
"id" : "0b6_g82",
"username" : "mark_louis_watson",
"name" : "Mark Louis Watson",
"link" : "",
"embed" : "",
"picture" : "",
"date_of_birth" : "1951",
"nationality" : "United States of America",
"gender" : "Male",
"profession" : "Author",
"metadata" : {
"connections" : {
"spouses" : "",
"books" : ""
You can get my Facebook information using my user name with the graph API: Adding required OpenGraph markup to your web pages is simple enough; for example, I added the following to my consulting web page:
    <meta property="og:title" content="Mark Watson: Ruby and Java Consultant" /> 
<meta property="og:type" content="consulting" />
<meta property="og:url" content="" />
<meta property="og:image" content="" />
There are other per-page attributes that you can optionally set.

There is a nice web app on Heroku that lets you check your meta data; for example: for my consulting page.

How does Open Graph compare to RDFa? RDFa is a much richer notation for at least two reasons: semantic markup can refer to elements on a web page and not the entire page, and you can use any Ontology in RDFa. Still, in my opinion, any semantic markup is a good thing.

For most web applications you really want to add Open Graph and RDFa markup automatically for data driven web pages. You might as well use both because even though it takes some effort, providing semantic markup may have a long tail of benefits.

No comments: