The Correct Approach To Markup "keywords" Of A Blog Post By Using Html5 And Microdata?
Solution 1:
Update: The definition of Schema.org’s keywords
property changed. Now it makes clear that it expects multiple tags, and that they should typically be comma-separated.
tl;dr: If you want to use a ul
element for your tags, using Schema.org’s keywords
property could look like this in Microdata:
<articleitemscopeitemtype="http://schema.org/BlogPosting"><footer><ulitemprop="keywords"><li><ahref="/tags/foo"rel="tag">foo</a>,</li><li><ahref="/tags/bar"rel="tag">bar</a></li></ul></footer></article>
If using it like that, you have to make sure that the ul
contains no other non-tag text.
HTML
The meta
element with the name
value keywords
offers a way to specify keywords that apply to the whole page. These keywords consist of text only, so you can’t use URIs.
So for the typical blog tags, you’d go the following way (possibly in addition to meta
-keywords
).
Link type
HTML5 defines the link type tag
:
The
tag
keyword indicates that the tag that the referenced document represents applies to the current document.
Note that this link type can only be used on single post pages as the tag always applies to the whole page.
(Attention: tag
is a Microformat, too, but it has a different definition: You may only use specially crafted URLs for the Microformat tag
.)
If your tags are more like categories (controlled vocabulary instead of free tagging), you could use the link type category
(possibly in combination with ).
Markup for the s
You might use a ul
or a dl
:
<ul><li><ahref="/s/foo" >foo</a></li><li><ahref="/s/bar" >bar</a></li></ul>
<dl><dt>Tags</dt><dd><ahref="/s/foo" >foo</a></dd><dd><ahref="/s/bar" >bar</a></dd></dl>
I’d go with the dl
when you also have other metadata to list, e.g. the author, publication date, etc.
A div
with comma-separated a
elements would work also, of course:
<div>Tags: <ahref="/s/foo" >foo</a>, <ahref="/s/bar" >bar</a></div>
Container for the list
The list should be part of a footer
element (inside the article
if you use one for your blog post):
A footer typically contains information about its section such as who wrote it, links to related documents, copyright data, and the like.
Vocabularies
Schema.org
CreativeWork
defines the property keywords
(BlogPosting
inherits it):
Keywords or s used to describe this content. Multiple entries in a keywords list are typically delimited by commas.
It expects plain text, so there’s no way to provide the URLs in Schema.org.
As keywords
expects a comma-separated list of s, dl
can’t be used (unless the dl
contains nothing else than s).
With an ul
, it could look like this in Microdata:
<ulitemprop="keywords"><li><ahref="/s/foo" >foo</a>,</li><li><ahref="/s/bar" >bar</a></li></ul>
If using a div
, you’d need to add another div
/child
so that the label "Tags:" gets not interpreted as itself:
<div>Tags: <spanitemprop="keywords"><ahref="/s/foo" >foo</a>, <ahref="/s/bar" >bar</a></span></div>
Common Tag
Common Tag is a (RDF) vocabulary for tagging. In contrast to Schema.org’s keywords
property it uses URIs for tags, not text only.
Example from their Quick Start Guide in RDFa:
<divxmlns:ctag="http://commontag.org/ns#" >
NASA's <atypeof="ctag:Tag"href="http://rdf.freebase.com/ns/en.phoenix_mars_mission"property="ctag:label">Phoenix Mars Lander</a> has deployed its robotic arm.
</div>
Explanation: The content is tagged () with a tag (
ctag:Tag
). This tag is defined () by the URI "http://rdf.freebase.com/ns/en.phoenix_mars_mission" and it’s called (
ctag:label
) "Phoenix Mars Lander"
Instead of ctag:Tag
you could use the class ctag:AuthorTag
(which means that it’s tagged by the content author).
MOAT
There is also the MOAT vocabulary, which stands for "Meaning Of A Tag". Unfortunately, their website seems to be gone (?).
An ontology that let users define relationships between Tag objects and URIs of Semantic Web resources
Post a Comment for "The Correct Approach To Markup "keywords" Of A Blog Post By Using Html5 And Microdata?"