RDFa OfferCatalog语法 [英] RDFa OfferCatalog Syntax

查看:111
本文介绍了RDFa OfferCatalog语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试找到使用RDFa将两个项目链接在一起的最佳方法,特别是将一个Person链接到多个SoftwareApplication条目.

I have been trying to find the best way to link two items together using RDFa, specifically linking a Person to multiple SoftwareApplication entries.

我目前在作者页面上执行此操作的方式是:

The way I currently do this on the author page is:

<div class="container text-center" vocab="http://schema.org/" typeof="Person">
...
<span property="hasOfferCatalog" typeof="OfferCatalog">
  <meta property="numberOfItems" content="10" />
  <span property="itemListElement" typeof="CreativeWork">
    <meta property="name" content="Project Name" />
    <meta property="url" content="https://www.my-domain.tld/ProjectName/" />
  </span>
...

如上所述,该项目实际上是一个SoftwareApplication,URL对此具有完整的RDFa/Schema.org定义,但如果我输入:

As above the project is actually a SoftwareApplication, and the URL has a complete RDFa/Schema.org definition of it, but if i put:

typeof="SoftwareApplication" 

然后,在作者的页面上,按某种预期,Google的结构化标记验证器会引发有关所需值不存在的错误,CreativeWork不会引发错误,但不那么具体.我真的不想在引用项目的任何地方重复整个SoftwareApplication元数据,我只想说去看看这个URL"即可.

on the author's page then, kind of expectedly, Google's Structured Markup validator throws errors about required values not being present for it, CreativeWork throws no errors but is less specific. I don't really want to repeat the entire SoftwareApplication metadata everywhere the project is referenced, I'd rather just say "go look at this URL".

从作者页面交叉引用SoftwareApplication页面的正确/最佳方法是什么?在项目中,反向引用很容易,因为有一个Author属性,该属性可以是Person类型,仅名称和URL就可以接受.

What is the correct/best way to cross reference the SoftwareApplication pages from the author page? in the project the reverse reference is easy as there is an Author attribute, which can be of type Person, which is acceptable with just name and URL.

一旦我知道了正确的RDFa引用方式,我会将标签应用于页面中的内容,而不是使用元标签.

Once I know the correct RDFa way of referencing I'll apply the tags to content in the page rather than using meta tags.

推荐答案

要将项目链接在一起,您需要一个合适的属性.类似于 author (说明PersonSoftwareApplication的创建者),或类似 hasOfferCatalog (说明Person提供的SoftwareApplication).

To link items together, you need a suitable property. Like author (to state which Person is the creator of the SoftwareApplication), or like hasOfferCatalog (to state which SoftwareApplication is offered by the Person).

在大多数情况下,Schema.org仅在一个方向上定义其属性.因此只有author,没有 authorOf .如果您需要将该属性用于其他方向,请可以使用RDFa的rev属性.

In most cases, Schema.org defines its properties only for one direction. So there is only author, and no authorOf. If you need the property for the other direction, you can use RDFa’s rev attribute.

如果您不想重复数据(即,仅定义一次并链接/引用此定义),则可以提供一个URL值.即使未将URL列为预期类型,Schema.org仍允许所有属性使用此属性.如果您要遵循语义网最佳实践,请为您的实体提供网址(

If you don’t want to repeat your data (i.e., only define it once and link/refer to this definition instead), you can provide a URL value. Schema.org allows this for all properties, even if URL is not listed as expected type. If you want to follow Semantic Web best practices, give your entities URLs (as identifiers) with RDFa’s resource attribute, and use these URLs as property values to refer to the entities.

为此,只需使用链接元素之一(例如,具有hrefsrc属性的元素).

For this, simply use one of the linking elements (e.g., elements with href or src attribute).

author情况为例:

<!-- on the page about the software: /software/5 -->

<div typeof="schema:SoftwareApplication" resource="/software/5#this">
  Author: 
  <a property="schema:author" typeof="schema:Person" href="/persons/alice#i">Alice</a>
</div>

<!-- on the page about the person: /persons/alice -->

<div typeof="schema:Person" resource="/persons/alice#i">
  Authored by:
  <a rev="schema:author" typeof="schema:SoftwareApplication" href="/software/5#this">Software 5</a>
</div>

Google SDTT中的错误

如果结构化数据测试工具给出了有关缺少属性的错误,请注意,这并不意味着您的标记有问题. Schema.org永远不需要属性.

Errors in Google’s SDTT

If the Structured Data Testing Tool gives errors about missing properties, note that it doesn’t mean that something is wrong with your markup. Schema.org never requires a property.

这仅表示这些属性是获得某些Google搜索功能所必需的.因此,如果您不想获得此功能(或者无法提供所有必需的属性),请忽略这些错误.

It just means that these properties are required for getting a certain Google search feature. So ignore these errors if you don’t want to get the feature (or if you can’t provide all required properties).

这篇关于RDFa OfferCatalog语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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