问题
After adding microdata to a page, I usually go to: https://developers.google.com/webmasters/structured-data/testing-tool/ to test it out and to make sure there's nothing missing.
I am getting the following error:
"ContactPoint must be attached to a parent with a declared type"
I am not sure what I am missing...?
Sample HTML
<div itemscope itemtype="http://schema.org/Person">
<p>
<span itemprop="description">Webmaster</span>:
<span itemprop="name">Omar</span>
<br/><a itemprop="url" href="https://plus.google.com/+Omar/">Profile</a>
</p>
<p itemscope itemtype="http://schema.org/ContactPoint">
To contact me please email me at
<a itemprop="email" href="mailto:omar@somewhere.com">omar@somewhere.com</a>
<meta itemprop="contactType" content="Webmaster"/>
<meta itemprop="sameAs" content="https://plus.google.com/+OmarJuvera"/>
<meta itemprop="availableLanguage" content="English"/>
<meta itemprop="availableLanguage" content="Spanish"/>
<meta itemprop="availableLanguage" content="Japanese"/>
</p>
</div>
回答1:
(While Google’s Testing Tool reports this as an error, it’s not an actual error. It should be a warning instead. Your code is valid Microdata and you are correctly using the Schema.org vocabulary.)
You have two top-level items (a
Person
and aContactPoint
), i.e., they are not related in any way.If you want to say that the
ContactPoint
is the contact point for thePerson
, then you need a property to connect these two items (the HTML-level nesting is not relevant here).Looking at the defined properties for Person, you can find the contactPoint property, which takes a
ContactPoint
as value and is defined as:A contact point for a person or organization.
So this property is appropriate for your case.
Add the
contactPoint
property to thePerson
item, referencing theContactPoint
item:<div itemscope itemtype="http://schema.org/Person"> … <p itemprop="contactPoint" itemscope itemtype="http://schema.org/ContactPoint"> … </p> </div>
来源:https://stackoverflow.com/questions/28334366/microdata-schema-org-seo-how-to-properly-set-a-contactpoint