2017-01-25 1 views
0

Ich bin beschäftigt, Mikrodaten (schema.org) zu einer Website über eine Softwareanwendung hinzuzufügen.schema.org itemref Fragen

Anstatt mich in Bezug auf doppelten Code zu wiederholen, versuche ich einmal (wenn möglich) Metadaten hinzuzufügen und darauf Bezug zu nehmen. Diese

ist, wo ich noch Fragen haben:

Wie richtig Sie ohne die Metadaten zu anderen Metadaten verweisen selbst auf der Seite hinzugefügt werden? Lassen Sie mich ein Beispiel geben: Zuerst versuchte ich dies:

<!DOCTYPE html> 
<html itemscope itemtype="http://schema.org/WebSite" lang="en"> 
<body itemprop="mainEntity" itemscope itemtype="http://schema.org/WebPage"> 
    <div class="main"> 
     <div class="container"> 
      <div class="row"> 
       <div class="col-md-12"> 
        <!-- info about product and reference to the metadata --> 
       <div itemscope itemtype="http://schema.org/SoftwareApplication" itemref="microdataMyProduct1"> 
        <!-- product info on website --> 
       </div> 
       </div> 
      </div> 
     </div> 
    </div> 

<!-- this metadata gets also added to the WebPage --> 
    <div id="microdataMyProduct1"> 
    <meta itemprop="name" content="My Product 1" /> 
    </div> 
</body> 
</html> 

Aber dieser Code über fügt auch das Mikro itemprop die des Produkts auf den Umfang der „Seite“. (Wo Google-Test-Tool beklagt, weil einige itemprop der von ‚SoftwareApplication‘ nicht gültig sind für ‚Webseite‘)

Also dachte ich einen Artikel Rahmen hinzufügen und ersetzen diese Zeilen:

<div itemscope itemtype="http://schema.org/SoftwareApplication" itemref="microdataMyProduct1"> 
<!-- ... --> 
<div id="microdataMyProduct1"> 
<!-- ... --> 

mit diesen Zeilen :

<div itemscope itemtype="http://schema.org/SoftwareApplication" itemref="microdataMyProduct1"> 
<!-- ... --> 
<div itemscope itemtype="http://schema.org/SoftwareApplication" id="microdataMyProduct1"> 
<!-- ... --> 

Das Problem ist, dass ich jetzt zwei itemscopes/itemtypes habe. Ist das richtig? In einem anderen stackoverflow-Post habe ich gelesen, dass Sie nicht itemref in Kombination mit IDs, sondern Verweis auf eine externe URL verwenden sollten. Ich bin verwirrt. Hier

ist ein Beispiel, das ich jetzt habe (Referenzierung auf mehr anderen Metadaten itemref (aus dem Innern des Kopf und in Mikro selbst):

<!DOCTYPE html> 
<html itemscope itemtype="http://schema.org/WebSite" lang="en"> 
<head> 
    <meta name="author" content="Company 1"> 
    <meta itemprop="author" itemscope itemtype="http://schema.org/LocalBusiness" itemref="microdataCompany1"> 
    <meta itemprop="about" itemscope itemtype="http://schema.org/SoftwareApplication" itemref="microdataMyProduct1"> 
    <!-- ... --> 
</head> 
<body itemprop="mainEntity" itemscope itemtype="http://schema.org/WebPage"> 
    <div itemprop="hasPart" itemscope itemtype="http://schema.org/WPHeader"> 
    <nav class="navbar" itemprop="hasPart" itemscope itemtype="http://schema.org/SiteNavigationElement"> 
     <!-- ... --> 
    </nav> 
    </div> 

    <div class="main"> 
     <div class="container"> 
      <div class="row"> 
       <div class="col-md-12"> 
        <!-- another second product on the page --> 
       <div itemscope itemtype="http://schema.org/SoftwareApplication"> 
        <h3 itemprop="name">Second Product</h3> 
        <meta itemprop="applicationCategory" content="BusinessApplication" /> 
        <meta itemprop="creator" itemscope itemtype="http://schema.org/LocalBusiness" itemref="microdataCompany1" /> 
        <meta itemprop="producer" itemscope itemtype="http://schema.org/LocalBusiness" itemref="microdataCompany1" /> 
        <meta itemprop="provider" itemscope itemtype="http://schema.org/LocalBusiness" itemref="microdataOtherCompany" /> 
        <!-- ... --> 
       </div> 
       </div> 
      </div> 
     </div> 
    </div> 

    <div class="footer" itemprop="hasPart" itemscope itemtype="http://schema.org/WPFooter"> 
    </div> 


    <!-- Product 1 microdata --> 
<!-- ##################### --> 
    <div hidden class="hidden" itemscope itemtype="http://schema.org/SoftwareApplication" id="microdataMyProduct1"> 
    <meta itemprop="name" content="My Product 1" /> 
    <meta itemprop="applicationCategory" content="BusinessApplication" /> 
    <meta itemprop="creator" itemscope itemtype="http://schema.org/LocalBusiness" itemref="microdataCompany1" /> 
    <meta itemprop="producer" itemscope itemtype="http://schema.org/LocalBusiness" itemref="microdataCompany1" /> 
    <meta itemprop="provider" itemscope itemtype="http://schema.org/LocalBusiness" itemref="microdataOtherCompany" /> 
    </div> 

<!-- Company 1 microdata --> 
<!-- ################### --> 
    <div hidden class="hidden" itemscope itemtype="http://schema.org/LocalBusiness" id="microdataCompany1"> 
     <meta itemprop="name" content="Company 1"> 
     <!-- ... --> 
     <div itemprop="openingHoursSpecification" itemscope itemtype="http://schema.org/OpeningHoursSpecification"> 
     <link itemprop="dayOfWeek" href="http://schema.org/Monday" /> 
     <time itemprop="opens" content="8:00:00" /> 
     <time itemprop="closes" content="12:30:00" /> 
     <time itemprop="opens" content="13:30:00" /> 
     <time itemprop="closes" content="18:00:00" /> 
     </div> 
     <div itemprop="openingHoursSpecification" itemscope itemtype="http://schema.org/OpeningHoursSpecification"> 
     <link itemprop="dayOfWeek" href="http://schema.org/Tuesday" /> 
     <time itemprop="opens" content="8:00:00" /> 
     <time itemprop="closes" content="12:30:00" /> 
     <time itemprop="opens" content="13:30:00" /> 
     <time itemprop="closes" content="18:0:00" /> 
     </div> 
    </div> 

<!-- Other Company microdata --> 
<!-- ######################## --> 
    <div hidden class="hidden" itemscope itemtype="http://schema.org/LocalBusiness" id="microdataOtherCompany"> 
     <meta itemprop="name" content="Other Company"> 
     <meta itemprop="legalName" content="Other Company Ltd."> 
     <div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"> 
     <meta itemprop="streetAddress" content="FooStreet"> 
     <!-- ... --> 
     </div> 
    </div> 
</body> 
</html> 

Ist die korrekte Verwendung von Mikrodaten für eine Seite auf einer Website ? über ein Produkt Sind itemref = „“ richtig verwendet Attribute

+0

Verwandte: [? Wie itemscope über mehrere HTML-Elemente spalten] (http://stackoverflow.com/q/29135360/1591669) – unor

Antwort

0

Sie nicht itemscope für reffering und reffered Element duplizieren sollte die korrekte Verwendung wird so sein:?.

<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
    <meta name="author" content="Company 1"> 
 
</head> 
 
<body> 
 
<main itemprop="mainEntity" itemscope itemtype="http://schema.org/WebPage"> 
 
    <div itemprop="hasPart" itemscope itemtype="http://schema.org/WPHeader"> 
 
    <nav class="navbar" itemprop="hasPart" itemscope itemtype="http://schema.org/SiteNavigationElement"> 
 
    </nav> 
 
    </div> 
 
    <div class="main"> 
 
    <div class="container"> 
 
     <div class="row"> 
 
     <div class="col-md-12"> 
 
      <div itemscope itemtype="http://schema.org/SoftwareApplication" itemref="microdataMyProduct1"> 
 
      </div> 
 
      <!-- another second product on the page --> 
 
      <div itemscope itemtype="http://schema.org/SoftwareApplication"> 
 
      <h3 itemprop="name">Second Product</h3> 
 
      <meta itemprop="applicationCategory" content="BusinessApplication" /> 
 
      <meta itemprop="creator" itemscope itemtype="http://schema.org/LocalBusiness" itemref="microdataCompany1" /> 
 
      <meta itemprop="producer" itemscope itemtype="http://schema.org/LocalBusiness" itemref="microdataCompany1" /> 
 
      <meta itemprop="provider" itemscope itemtype="http://schema.org/LocalBusiness" itemref="microdataOtherCompany" /> 
 
      </div> 
 
     </div> 
 
     </div> 
 
    </div> 
 
    </div> 
 
    <div class="footer" itemprop="hasPart" itemscope itemtype="http://schema.org/WPFooter"> 
 
    </div> 
 
</main> 
 
    <!-- Product 1 microdata --> 
 
    <!-- ##################### --> 
 
    <div hidden class="hidden" id="microdataMyProduct1"> 
 
    <meta itemprop="name" content="My Product 1" /> 
 
    <meta itemprop="applicationCategory" content="BusinessApplication" /> 
 
    <meta itemprop="creator" itemscope itemtype="http://schema.org/LocalBusiness" itemref="microdataCompany1" /> 
 
    <meta itemprop="producer" itemscope itemtype="http://schema.org/LocalBusiness" itemref="microdataCompany1" /> 
 
    <meta itemprop="provider" itemscope itemtype="http://schema.org/LocalBusiness" itemref="microdataOtherCompany" /> 
 
    <meta itemprop="image" content="http://example.com/example.gif" /> 
 
    </div> 
 
    <!-- Company 1 microdata --> 
 
    <!-- ################### --> 
 
    <div hidden class="hidden" id="microdataCompany1"> 
 
    <meta itemprop="name" content="Company 1"> 
 
    <meta itemprop="image" content="http://example.com/example.gif" /> 
 
    <div itemprop="openingHoursSpecification" itemscope itemtype="http://schema.org/OpeningHoursSpecification"> 
 
     <link itemprop="dayOfWeek" href="http://schema.org/Monday" /> 
 
     <time itemprop="opens" content="8:00:00" /> 
 
     <time itemprop="closes" content="12:30:00" /> 
 
     <time itemprop="opens" content="13:30:00" /> 
 
     <time itemprop="closes" content="18:00:00" /> 
 
    </div> 
 
    <div itemprop="openingHoursSpecification" itemscope itemtype="http://schema.org/OpeningHoursSpecification"> 
 
     <link itemprop="dayOfWeek" href="http://schema.org/Tuesday" /> 
 
     <time itemprop="opens" content="8:00:00" /> 
 
     <time itemprop="closes" content="12:30:00" /> 
 
     <time itemprop="opens" content="13:30:00" /> 
 
     <time itemprop="closes" content="18:0:00" /> 
 
    </div> 
 
    </div> 
 
    <!-- Other Company microdata --> 
 
    <!-- ######################## --> 
 
    <div hidden class="hidden" id="microdataOtherCompany"> 
 
    <meta itemprop="name" content="Other Company"> 
 
    <meta itemprop="image" content="http://example.com/example.gif" /> 
 
    <meta itemprop="legalName" content="Other Company Ltd."> 
 
    <div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"> 
 
     <meta itemprop="streetAddress" content="FooStreet"> 
 
    </div> 
 
    </div> 
 
</body> 
 
</html>

+1

sind Sie sicher? weil Sie jetzt Eigenschaften von "microdataMyProduct1" zu WebPage hinzufügen. Dies führt zu Fehlern wie "applicationCategory: BusinessApplication (Google erkennt die Eigenschaft applicationCategory für ein Objekt vom Typ WebPage nicht.) Sie können Ihr Codefragment testen: https://search.google.com/structuredata/testing- Werkzeug Sie stehen vor dem Problem jetzt, dass ich in meinem Beitrag erwähnt ... – juFo

+0

Ok, ich habe Code bearbeitet. 'WebSite' wird entfernt,' WebPage' wird verlagert. – br3t

+0

Dies ist ein Temp-Fix, wie andere Objekte sein könnten hinzugefügt/verschachtelt, was zu dem gleichen Problem führt ... – juFo

Verwandte Themen