我正在为tinymce编辑器构建一个插件,它为选定的文本添加了一些微数据,我想确保最终的标记是有效的.作为指定由微数据草案规范,一个新的项目是通过将属性中指示itemscope的元素,例如:
<section itemscope itemtype="http://example.com/vocab/someobject" itemid="someid" >
<meta itemprop="topic" content="something very interesting" />
....
other microdata stuff
</section>
Run Code Online (Sandbox Code Playgroud)
我已经扩展了tinymce的配置参数来识别这些微数据属性:
tinyMCE.init({
...
schema: "html5",
extended_valid_elements:"@[itemscope|itemtype|itemid|itemprop|content],div,span,time[datetime]"
...
});
Run Code Online (Sandbox Code Playgroud)
事情一般都在发挥作用.但是,当我使用插件时,微小的mce仍然通过向itemscope属性添加一个空值来"纠正"我的标记,如下所示:itemscope="".但是itemscope属性是一个布尔元素,AFAIU意味着它应该没有值.
所以问题是,a)如果itemscope属性有值,它仍然是有效的标记吗?和b)如果没有,(怎么样)我可以配置tinymce将itemscope作为一个合适的布尔属性,而不是附加=""位?
谢谢!
用作参考:https://support.google.com/webmasters/answer/146750?hl = zh-CN
您会在"产品"下注意到有一个类别属性,而且页面下方有一个示例:
<span itemprop="category" content="Hardware > Tools > Anvils">Anvils</span>
Run Code Online (Sandbox Code Playgroud)
我完全模仿了:
<span itemprop="category" content="kitchen sinks > stainless steel sinks > undermount">undermount</span>
Run Code Online (Sandbox Code Playgroud)
然而,当我使用Google的结构化数据工具测试它时,我收到错误:
错误:页面包含属性"类别",它不是架构的一部分.
我在例子中也意识到,它使用的是data-vocabulary.org→Product,我在使用schema.org→Product.
现在在http://schema.org/Product上,它没有提到任何类别.schema.org不提供类别吗?或者我错过了什么?
对于网页的其他区域,标记起来很简单; 即导航元素,页眉,页脚,侧边栏
不是这样mainContentOfPage; 我已经看到了很多不同的方法来实现这一点,最近(我发现这个是最奇怪的)在schema.org本身:
<div itemscope itemtype="http://schema.org/Table">
<meta itemprop="mainContentOfPage" content="true"/>
<h2 itemprop="about">list of presidents</h2>
<table>
<tr><th>President</th><th>Party</th><tr>
<tr>
<td>George Washington (1789-1797)</td>
<td>no party</td>
</tr>
<tr>
<td>John Adams (1797-1801)</td>
<td>Federalist</td>
</tr>
...
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
我可以用一些例子; 我的页面的主要内容在这种情况下是搜索结果页面,但我也打算在其他页面上使用它(主页,产品页面等)
编辑,我发现了一些更多的例子:
这有效吗?我在博客上发现了这个:
<div id="main" itemscope itemtype="http://schema.org/WebPageElement" itemprop="mainContentOfPage">
<p>The content</p>
</div>
Run Code Online (Sandbox Code Playgroud)
我还在另一个博客上发现了这个更简单的例子(可能太简单了?):
<div id="content" itemprop="mainContentOfPage">
<p>The content</p>
</div>
Run Code Online (Sandbox Code Playgroud) 哪一个是正确的?
<link itemprop="availability" href="http://schema.org/InStock">
?<meta itemprop="availability" content="InStock" />
<span itemprop="availability" content="in_stock"></span>
Run Code Online (Sandbox Code Playgroud)
我查看了官方架构文档,并在示例中找到了所有这些文档.
我想他们所有人都会工作,但目前,有没有首选标准?
我是微数据的新手,我有以下方案,我想要一些帮助:
我希望将微数据放在产品页面上,在页面上,同一产品可能存在多种变体.每个变体都有相同的名称,描述和图像,但它们各自有自己的SKU,颜色,大小,重量和价格.
在页面上我有类似的东西
<section id="commonparts">
<h1>Product name</h1>
<div><img src="productimage"></div>
<div>Product description</div>
</section>
<section id="variations">
<div id="variation1">
<div>SKU 1</div>
<div>Colour 1</div>
<div>Size 1</div>
<div>Price 1</div>
</div>
<div id="variation2">
<div>SKU 2</div>
<div>Colour 2</div>
<div>Size 2</div>
<div>Price 2</div>
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
有可能微观数据吗?
提前致谢
假设有一个简单的问题并回答HTML并想添加微数据,应该如何进行?
<h2>My Question</h2>
<p>My Answer</p>
Run Code Online (Sandbox Code Playgroud)
我知道schema.org的例子,但我不太清楚.看起来有点矫枉过正.我需要一个简单的解决方案 我可以这样做吗?
<h2 itemscope itemtype="http://schema.org/Question">My Question</h2>
<p itemscope itemtype="http://schema.org/Answer">My Answer</p>
Run Code Online (Sandbox Code Playgroud)
我只想说出问题是什么,答案是什么.这对搜索引擎来说足够了吗?或者我应该有更复杂的东西,如:
<div itemscope itemtype="http://schema.org/Question">
<h2 itemprop="name">My Question</h2>
<p itemscope itemtype="http://schema.org/Answer">My Answer</p>
</div>
Run Code Online (Sandbox Code Playgroud)
用itemprop="name"正确的方法来说出问题是什么?是什么区别itemprop="name",并itemprop="text"在上面提到的schema.org的例子吗?
我正在使用一些Microdata来描述一篇博文,我BlogPosting对Google Developers Testing Tool 对Schema.org的价值回报感到惊讶.
我原以为它是itemprop url,而不是网站URL和项目的合并id.
我做错了什么,还是只是谷歌显示问题?
<div itemscope="itemscope"
itemprop="blogPost"
itemtype="http://schema.org/BlogPosting"
id="foobar">
<a itemprop="url" href="/realone">real</a>
</div>
Run Code Online (Sandbox Code Playgroud)
https://developers.google.com/structured-data/testing-tool/返回的值:
BlogPosting: http://www.example.com/foobar
url: http://www.example.com/realone
Run Code Online (Sandbox Code Playgroud) 我目前实现了像这样的面包屑:
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="HOME URL" itemprop="url">
<span itemprop="title">HOME TITLE</span>
</a> >
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="1ST LEVEL URL" itemprop="url">
<span itemprop="title">1ST LEVEL TITLE</span>
</a> >
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<span itemprop="title">CURRENT TITLE</span>
</div>
Run Code Online (Sandbox Code Playgroud)
如您所见,我没有为当前页面指定一个URL,这将是多余的.但是,当我尝试使用Google测试工具时,我收到一条错误消息,指出当前页面痕迹的网址丢失了.
鉴于此,我有三个选择,我可以想到.
我为当前页面指定了一个url:
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="HOME URL" itemprop="url">
<span itemprop="title">HOME TITLE</span>
</a> >
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="1ST LEVEL URL" itemprop="url">
<span itemprop="title">1ST LEVEL TITLE</span>
</a> >
</div>
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="CURRENT LEVEL URL" itemprop="url">
<span itemprop="title">CURRENT TITLE</span> …Run Code Online (Sandbox Code Playgroud) 我正在尝试为重置密码的Gmail收件箱操作获取正确的标记.我正在使用电子邮件标记测试程序.
我的标记看起来像这样:
<div itemscope itemtype="http://schema.org/EmailMessage">
<meta itemprop="description" content="Reset password instructions"/>
<div itemprop="potentialAction" itemscope itemtype="http://schema.org/ViewAction">
<meta itemprop="target" content="https://www.example.com/users/password/new?token=123"/>
<meta itemprop="name" content="Reset Your Password"/>
</div>
<meta itemprop="description" content="Visit our site to reset your password."/>
</div>
Run Code Online (Sandbox Code Playgroud)
上面的标记返回错误:
url字段的值是必需的.
但我无法弄清楚该url字段应如何插入标记.甚至谷歌的例子都没有通过他们的标记验证器.
我试图弄清楚如何使用Schema.org对象中的isPartOf属性。WebPage
据我了解,这应该用于指定您的页面是集合的一部分。所以我有一份曲棍球队名单,然后是一份球员名单。我的理解是单个球员将成为团队的一部分,因此大概在球员 HTML 页面上,我会添加该isPartOf元素。
但我不确定如何添加它。我应该将它作为 URL 添加到页面集合中吗?或者我应该只添加一个meta带有集合名称的标签?我似乎在任何地方都找不到关于这个元素的太多信息。有谁知道如何正确使用它?
microdata ×10
schema.org ×8
html ×4
breadcrumbs ×1
gmail ×1
html-email ×1
html5 ×1
seo ×1
tinymce ×1