I've this kind of structure:
+ EVENT -> itemtype="http://schema.org/Event
+ Name
+ Date
+ ...
+ LOCATION -> itemtype="http://schema.org/Place
* Name
+ Url
+ ...
I won't show all the Place information on the website, but I want to use the information for Microdata. And so I want to add this tag:
<meta itemprop="location" itemscope itemtype="http://schema.org/Place">
Works fine.
But how can I add the itemprops for name
, url
, "address" for location
?
It won't works like :
<meta itemprop="location" itemscope itemtype="http://schema.org/Place">
<meta itemprop="url" content="https://example-location.com">
<meta itemprop="name" content="exampleLocationName">
Probably like this. Actually unsure of it.
<meta itemprop="location" content="" itemscope itemtype="http://schema.org/Place" itemref="place-url place-name">
<link id="place-url" itemprop="url" href="https://example-location.com">
<meta id="place-name" itemprop="name" content="exampleLocationName">
content
?https://www.w3.org/TR/microdata#x7-2-content-models
If a
meta
element has anitemprop
attribute, thename
,http-equiv
, andcharset
attributes must be omitted, and thecontent
attribute must be present.
You can't.
<link>
instead of <meta>
? Because only URL property elements can have an absolute URL as their values, and <link>
is one while <meta>
is not.
The algorithm to determine the value for a name-value pair is given by applying the first matching case in the following list:
- If the element also has an
itemscope
attribute: the value is the item created by the element.- If the element has a
content
attribute: the value is thetextContent
of the element'scontent
attribute.
The URL property elements are the
a
,area
,audio
,embed
,iframe
,img
,link
,object
,source
,track
, andvideo
elements.
If a property's value , as defined by the property's definition, is an absolute URL , the property must be specified using a URL property element .
<meta>
tags? You cannot, as the <meta>
is a void element , which must not have any children.
Have you considered using JSON-LD instead?
You have to wrap the event microdata inside the Event entity. In your specific case:
<div itemscope itemtype="http://schema.org/Event">
<h1 itemprop="name">Name</h1>
<time itemprop="startDate" datetime="2018-07-28T20:23:16+02:00" content="2018-07-28T20:23:16+02:00">28 luglio 2018</time>
...
<div itemprop="location" itemscope itemtype="https://schema.org/Place">
<h2>Location: <span itemprop="name">Location Name</span></h2>
<meta itemprop="url" content="https://example-location.com">
</div>
</div>
If you want to hide all the location informations, you can act as above but hide the whole Event entity:
<div itemscope itemtype="http://schema.org/Event">
...
<div style='display: none;' itemprop="location" itemscope itemtype="https://schema.org/Place">
<meta itemprop="name" content="Location Name">
<meta itemprop="url" content="https://example-location.com">
</div>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.