如何在WebPage元素中放置文章?

时间:2015-01-20 14:55:55

标签: html html5 schema.org microdata google-rich-snippets

所以我有一个WebPage,在WebPage里面我有一个Article。 现在我知道这不是问题,但是当我使用这个工具时: https://developers.google.com/webmasters/structured-data/testing-tool/

我注意到WebPage没有namedescription等元素,在这种情况下我应该怎么办?应该忽略它吗?因为即使我为名称和描述设置了meta标签,它也会与Article设置100%相同,然后它可能会使内容加倍或加倍,我该怎么办?

我的页面示例:

<html>
<head>
<title></title>
</head>
<body itemscope itemtype="http://schema.org/WebPage">
    <nav class="navbar navbar-default" role="navigation" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement"> HERE COME THE NAVIGATION CODE 
    </nav>

    <main itemscope itemtype="http://schema.org/Article">
    <h1 itemprop="name">Name</h1>
    <p itemprop="description">Description</p>
    </main>

    <div id="some-links">
             <ul>
              <li><a itemprop="relatedLink" href="" class="active"><span class="icon icon-eye"></span> Cat Overview</a></li>
              <li><a itemprop="relatedLink" href=""><span class="icon icon-dog"></span> Cat Breeds</a></li>
              <li><a itemprop="relatedLink" href=""><span class="icon icon-article"></span> Cat Articles</a></li>
              <li><a itemprop="relatedLink" href=""><span class="icon icon-paw"></span> Cat Adoption</a></li>
            </ul>
    </div>

</main>

</body>
</html>

2 个答案:

答案 0 :(得分:0)

您的WebPage 为空。它有5个relatedLink属性。但即使它是空的,也不会有问题。

name的{​​{1}}可能是您的WebPage元素的值(例如,通常包括网页网站名称),而title name的{​​1}}可以是页面标题的值(例如,通常没有网站名称)。

您可以将ArticleSiteNavigationElement项目相关联(目前这两项都是顶级项目,彼此无关),例如使用hasPart property

WebPage

我猜相同的属性可用于将<body itemscope itemtype="http://schema.org/WebPage"> <nav itemprop="hasPart" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement"></nav> </body> WebPage相关联。遗憾的是,Schema.org缺少用于表示Article的主要内容/项目的属性(mainContentOfPage无法使用)。

答案 1 :(得分:0)

像这样:

<html>
<body itemscope itemtype="http://schema.org/WebPage">
    <article itemprop="mainEntity" itemscope itemtype="http://schema.org/Article">
        <meta itemscope itemprop="mainEntityOfPage"  itemType="https://schema.org/WebPage" itemid="https://google.com/article"/>
        <h2 itemprop="headline">Article headline</h2>
        <h3 itemprop="author" itemscope itemtype="https://schema.org/Person">
            By <span itemprop="name">John Doe</span>
        </h3>
        <span itemprop="description">A most wonderful article</span>
        <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
            <img src="https://google.com/thumbnail1.jpg"/>
            <meta itemprop="url" content="https://google.com/thumbnail1.jpg">
            <meta itemprop="width" content="800">
            <meta itemprop="height" content="800">
        </div>
        <div itemprop="publisher" itemscope itemtype="https://schema.org/Organization">
            <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">
                <img src="https://google.com/logo.jpg"/>
                <meta itemprop="url" content="https://google.com/logo.jpg">
                <meta itemprop="width" content="600">
                <meta itemprop="height" content="60">
            </div>
            <meta itemprop="name" content="Google">
        </div>
        <meta itemprop="datePublished" content="2015-02-05T08:00:00+08:00"/>
        <meta itemprop="dateModified" content="2015-02-05T09:20:00+08:00"/>
    </article>
</body>
</html>

来源onetwo