The keywords
property from Schema.org, as it being in plural form suggests, seems to imply its value should be a line of comma-separated text. Like the following example:
<p itemprop="keywords">lorem, ipsum, dolor, sit, amet</p>
That reminds me of the <meta name="keywords" content="lorem, ipsum, dolor, sit, amet">
tag we used to put within <head></head>
for SEO reason.
However, from semantics' perspective, I think the above example is incorrect because keywords should be a list of words. Thus it should be markuped by using the <ul>
element.
Is there a common consensus on how the keywords of a blog post should be markuped by using HTML5 and Microdata?
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:
<article itemscope itemtype="http://schema.org/BlogPosting">
<footer>
<ul itemprop="keywords">
<li><a href="/tags/foo" rel="tag">foo</a>,</li>
<li><a href="/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 tag
).
Markup for the tags
You might use a ul
or a dl
:
<ul>
<li><a href="/tags/foo" rel="tag">foo</a></li>
<li><a href="/tags/bar" rel="tag">bar</a></li>
</ul>
<dl>
<dt>Tags</dt>
<dd><a href="/tags/foo" rel="tag">foo</a></dd>
<dd><a href="/tags/bar" rel="tag">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: <a href="/tags/foo" rel="tag">foo</a>, <a href="/tags/bar" rel="tag">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 tags 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 tag URLs in Schema.org.
As keywords
expects a comma-separated list of tags, dl
can’t be used (unless the dl
contains nothing else than tags).
With an ul
, it could look like this in Microdata:
<ul itemprop="keywords">
<li><a href="/tags/foo" rel="tag">foo</a>,</li>
<li><a href="/tags/bar" rel="tag">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 tag itself:
<div>Tags: <span itemprop="keywords"><a href="/tags/foo" rel="tag">foo</a>, <a href="/tags/bar" rel="tag">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:
<div xmlns:ctag="http://commontag.org/ns#" rel="ctag:tagged">
NASA's <a typeof="ctag:Tag"
rel="ctag:means"
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 (ctag:tagged
) with a tag (ctag:Tag
). This tag is defined (ctag:means
) 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