RDFa OfferCatalog Syntax

只愿长相守 提交于 2019-12-20 04:18:41

问题


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>
...

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" 

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".

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.

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


回答1:


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).

Inverse properties

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.

Linking instead of repeating

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.

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

Example

Using the author case as example:

<!-- 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>

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.

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).




回答2:


Thank you for the other response, I'll have a read over the linked resources, I have also found a solution to the specific case in my question.

Google Search Console has a page on Carousels which shows that you can use ListItem, which only "needs" URL, to populate the hasOfferCatalog property. E.g.

<span property="itemListElement" typeof="ListItem">
  <meta property="position" content="1" />
  <meta property="url" content="https://www.my-domain.tld/ProjectName/" />
</span>


来源:https://stackoverflow.com/questions/46017381/rdfa-offercatalog-syntax

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!