标记“关键字”的正确方法使用HTML5和Microdata的博客文章? [英] The correct approach to markup "keywords" of a blog post by using HTML5 and Microdata?

查看:153
本文介绍了标记“关键字”的正确方法使用HTML5和Microdata的博客文章?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自Schema.org的关键字属性,因为它以复数形式表示,似乎暗示它的值应该是一行以逗号分隔的文本的。如下例所示:

 < p itemprop =keywords> lorem,ipsum,dolor,sit,amet< / p为H. 

这让我想起< meta name =keywordscontent =搜索引擎优化中使用的lorem,ipsum,dolor,sit,amet>< / code>标签原因。



但是,从语义学的角度来看,我认为上面的例子是不正确的,因为关键字应该是一个单词列表。因此,应使用< ul> 元素进行标记。



是否就如何博客文章的关键词应该使用HTML5和Microdata来标记?

Schema.org的关键字属性发生更改。现在它清楚地表明它期望多个标签,并且它们通常应该用逗号分隔。

tl; dr :如果您想要使用Schema.org的关键字属性,可以在Microdata中使用 ul 元素作为标签:

 < article itemscope itemtype =http://schema.org/BlogPosting> 

< footer>
< ul itemprop =keywords>
< li>< a href =/ tags / foo =tag> foo< / a>,< / li>
< li>< a href =/ tags / bar =tag> bar< / a>< / li>
< / ul>
< / footer>

< / article>

如果像这样使用它,您必须确保 ul 不包含其他非标记文本。






HTML



meta 元素的名称 关键字 优惠一种指定适用于整个页面的关键字的方法。这些关键字仅包含文本,因此您不能使用URI。



因此,对于典型的博客标签,您可以采用以下方式(可能除 meta - 关键字)。



链接类型



HTML5定义了 link type tag 标记关键字表示引用的文档所代表的标记适用于当前文档。


请注意,此链接类型只能用于单个帖子页面,因为该标签始终适用于整个页面。



(注意: tag Microformat ,它也有不同的定义:您只能为Microformat 标签使用经特殊设计的网址。)



如果您的标签更像是类别(受控词汇而不是免费标签),您可以使用链接类型类别 (可能与标签结合使用)。



标记的标记



您可以使用 ul dl

 < ul> 
< li>< a href =/ tags / foo =tag> foo< / a>< / li>
< li>< a href =/ tags / bar =tag> bar< / a>< / li>
< / ul>



 < dl> 
< dt>标签< / dt>
< dd>< a href =/ tags / foo =tag> foo< / a>< / dd>
< dd>< a href =/ tags / bar =tag> bar< / a>< / dd>
< / dl>

当我使用 dl 时你也有其他的元数据列表,例如作者,出版日期等。

<用逗号分隔的 a div / code>元素也可以工作,当然:
$ b < div>标记:< a href =/ tags / foo =tag> foo< / a>,< a href =/ tags / bar =tag> bar< / a>< / DIV>



列表的容器



列表应该是的一部分 footer 元素(位于文章内) $ b


页脚通常包含有关其部分的信息,例如谁




词汇表



Schema.org



CreativeWork 定义属性 关键字 BlogPosting 继承它):


用于描述此内容的关键字或标签。关键字列表中的多个条目通常用逗号分隔。


它需要纯文本,因此无法提供标记URL Schema.org。



As keywords 需要逗号分隔的标签列表, dl 不能使用(除非 dl 包含标签以外的内容)。

使用 ul ,它在Microdata中看起来像这样:

 < ul itemprop =keywords> 
< li>< a href =/ tags / foo =tag> foo< / a> ;,< / li>
< li>< a href =/ tags / bar =tag> bar< / a>< / li>
< / ul>

如果使用 div ,你会需要添加另一个 div / child ,这样标签Tags:不会被解释为标签本身:

 < div>标签:< span itemprop =keywords>< a href = / tags / foo =tag> foo< / a>,< a href =/ tags / bar =tag> bar< / a>< / span> DIV> 



常用标记



Common Tag 是一种用于标记的(RDF)词汇表。与Schema.org的关键字属性相反,它使用URI作为标记,而不是仅使用文本。



来自他们的< a href =http://commontag.org/QuickStartGuide#Quick_Start =nofollow noreferrer> RDFa快速入门指南: > < div xmlns:ctag =http://commontag.org/ns# =ctag:tagged>
NASA< a typeof =ctag:Tag
rel =ctag:表示
href =http://rdf.freebase.com/ns/en.phoenix_mars_mission
property =ctag:label> Phoenix Mars Lander< / a>部署了机器人手臂。
< / div>

说明:内容被标记( ctag:tagged )和一个标签( ctag:Tag )。通过URI ctag:表示) nofollow noreferrer> http://rdf.freebase.com/ns/en.phoenix_mars_mission 并且它被称为( ctag:label )Phoenix Mars Lander



可以使用类 ctag:AuthorTag ctag:Tag c $ c>(这意味着它由内容作者标记)。



MOAT



MOAT词汇表,代表标签的含义。不幸的是,他们的网站似乎已经消失了(?)。


允许用户定义标签对象与语义Web资源的URI之间的关系的本体



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

这篇关于标记“关键字”的正确方法使用HTML5和Microdata的博客文章?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆