如何为Microdata嵌套<meta />标签?

时间:2017-02-02 15:56:45

标签: html5 meta schema.org microdata

我有这种结构:

+ EVENT -> itemtype="http://schema.org/Event
 + Name   
 + Date   
 + ...
 + LOCATION -> itemtype="http://schema.org/Place
        *          Name
     + Url
     + ...

我不会在网站上显示所有地方信息,但我想使用Microdata的信息。 所以我想添加这个标签:

<meta itemprop="location" itemscope itemtype="http://schema.org/Place">

工作正常。

但是如何为name的{​​{1}},url,“地址”添加itemprop?

它不会像:

location

2 个答案:

答案 0 :(得分:1)

大概是这样。其实不确定。

<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

     

如果meta元素具有itemprop属性,则必须省略namehttp-equivcharset属性,而{{1} }属性必须存在。

你不能。

为什么用content代替<link>

因为只有 URL属性元素可以具有绝对URL 作为其值,而<meta>是一个,而<link>不是。

来自https://www.w3.org/TR/microdata#x5-4-values-the-content-attribute-element-specific-attributes-and-element-content

  

用于确定名称/值对的值的 算法 由   在以下列表中应用第一个匹配的大小写:

     
      
  • 如果元素还具有<meta>属性:该值为项目   由元素创建。
  •   
  • 如果元素具有itemscope属性:该值为content   元素的textContent属性。
  •   

  

URL属性元素 contentaareaaudio,{{1 }},embediframeimglinkobjectsource元素。

  

如果由属性定义定义的属性的 value 绝对URL ,则必须使用 URL属性元素指定该属性>。

如何嵌套track标签?

您不能这样做,因为video void元素,该元素不能有任何子元素。


更好

您是否考虑过使用using JSON-LD

答案 1 :(得分:0)

您必须将事件微数据包装在Event实体内。在您的特定情况下:

o.stud_data[i]['name'] How to Decode this name field in my listing page

如果您要隐藏所有位置信息,则可以按照上述步骤操作,但要隐藏整个事件实体:

<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>
相关问题