为什么我的食谱需要 url?

Why does my Recipe need a url?

我正在使用 Google 的富文本工具 1 测试我的模式,它一直告诉我我的 Recipe 项目需要 url 属性。

The documentation 状态:

Errors indicate either missing required fields or syntax errors.

我收到的错误是字段 url 为空,不应该为空。但是,我不知道应该填写什么。我的意思是,显然该工具需要 URL,但是 - 从语义上讲 - URL 应该去哪里?如果我没有要指向的 URL 怎么办?

如果我决定将假定的必填字段留空,是否意味着完整的 Recipe 将不是有效的架构?或者只是它缺少一个字段?

<body itemscope itemtype="http://schema.org/WebPage">
    <main>
        <header itemscope itemtype="http://schema.org/Country" itemprop="about">
            <h1 itemprop="name">France</h1>
            <p>
                <span class="capital" title="Capital" itemprop="containsPlace">Paris</span>
                <span title="Member of the EU since 1958" itemprop="additionalProperty" itemscope itemtype="http://schema.org/PropertyValue">
                    <meta itemprop="name" content="Member of the EU since">
                    <span itemprop="value" class="member-since">1958</span>
                </span>
            </p>
        </header>
        <div itemprop="mainEntity" itemscope itemtype="http://schema.org/ItemList">
            <meta itemprop="description" content="Recipes that are particular for France">
            <article class="recipe loading" id="recipe-1" data-recipe="" itemref="img-0" itemprop="itemListElement" itemscope itemtype="http://schema.org/Recipe">
                <meta itemprop="position" content="1">
                <aside class="media">
                    <img itemprop="image" id="img-0" src="https://s-media-cache-ak0.pinimg.com/originals/ef/4c/5c/ef4c5c0b008d11710caa7a10f502d288.jpg">
                    <div itemscope itemtype="http://schema.org/VideoObject" class="youtube">
                        <a itemprop="contentUrl" href="https://www.youtube.com/watch?v=fHgULHwyZJo" title="Watch a video on how to make Eclair">
                            <meta itemprop="name" content="Making éclairs">
                            <meta itemprop="uploadDate" content="2016-07-12">
                            <meta itemprop="description" content="In this video you'll learn how to make éclairs">
                            <img itemprop="thumbnailUrl" src="https://i.ytimg.com/vi/fHgULHwyZJo/maxresdefault.jpg" alt="Eclairs tutorial">
                        </a>
                        <iframe href="https://www.youtube.com/watch?v=fHgULHwyZJo" title="YouTube video player" frameborder="0" allowfullscreen="1" width="640" height="360" src="https://www.youtube.com/embed/fHgULHwyZJo?enablejsapi=1&amp;autoplay=1&amp;modestbranding=1&amp;rel=0&amp;showInfo=0&amp;origin=http%3A%2F%2Flocalhost&amp;widgetid=1"></iframe>
                    </div>
                </aside>
                <div class="text">
                    <div class="wiki-text">
                        <h1 itemprop="name">Eclairs</h1>
                        <p itemprop="description">An éclair is an oblong pastry made with choux dough filled with a cream and topped with icing. The dough, which is the same as that used for profiterole, is typically piped into an oblong shape with a pastry bag and baked until it is crisp and hollow
                            inside. </p>
                        <p class="read-more">For more information about <span class="recipe-name">Éclair</span>, read the <a href="https://en.wikipedia.org/wiki/%C3%89clair" title="Wikipedia page about %C3%89clair" itemprop="sameAs">Wiki</a>.</p>
                    </div>
                    <div class="rating" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
                        Rated <span itemprop="ratingValue">3.5</span>/5 based on <span itemprop="reviewCount">11</span> customer reviews
                    </div>
                    <div class="cooking">
                        <h2>Bake it yourself!</h2>
                        <div>
                            <meta itemprop="cookTime" content="PT50M">
                            <span>Bake time: 50 minutes</span>
                        </div>
                    </div>
                </div>
            </article>
        </div>
    </main>
</body>

1 相关问题:

URL 参数应包含可以使用浏览器查看您的项目的基本网址。

此参数对于通过智能内容工具和搜索机器人(如 Google)为您的内容编制索引非常重要。一旦您提供它,Google 将能够 link 对您的项目的任何引用到已声明的 URL。

当您的网络应用程序在不同设备的不同地址提供相同内容时,此参数很重要。通过提供相同的 URL 参数,您可以避免对重复内容的任何最终处罚。

URL 参数通常是 permalink 的基本(未美化)版本,尤其是在使用 WordPress 等流行网站引擎时,您可以在其中更改 permalinks 结构,但基础 url 方案(通常采用 /?p=id 的形式 - 其中 id 是文章的 ID)将始终有效。这样您就可以确保,即使您决定在一段时间后更改 permalinks 结构,您对该内容的排名和索引也不会受到影响,因为声明的 URL 将保持不变和旧的 links 将工作,不管你的 pretty-permalinks 当前方案如何。

声明的URL参数还避免了索引服务的另一个常见问题:

例如,如果您为每月的特色食谱提供 link,如果搜索引擎使用 "this months hot recipe link" 为当前食谱编制索引,那么人们何时会寻找它(基于索引文本或成分)下个月,他们会找到另一个食谱,这不是他们正在寻找的,所以他们会点击后退按钮 急躁,因此:

  • 没有找到他们要找的东西,尽管它在您的网站上并且
  • 损害您的排名,因为 Google 监控用户行为,每当他们返回时,这显然意味着当前索引的内容对于该搜索是错误的。

为菜谱提供 URL 将允许搜索引擎正确索引和 link 它,这样想看它的人就可以看到它,这样你的排名就会在他们消费的同时上升在您的网站上阅读食谱或为其添加书签时的时间。

Google 的 SDTT 中显示的错误并不意味着您的 Schema.org 标记中存在实际错误(因为 不是 提供url 属性 完全没问题)。它正在检查您的标记是否符合 Google 的 Recipes 丰富卡片指南。如果你不关心它,你什么都不用做。

如果您关心 Recipes 丰富卡片:

Google 需要 url 属性 用于 list of recipes 中的每个 ListItem(即每个 Recipe):

ListItem.url
URL, required

The canonical URL of the item page. Every item should have a unique URL.

虽然您可以使用片段(如 #recipe-2#recipe-3 等)实现 "unique URL[s]",但指南说 "item page",因此 Google 似乎想查看每个食谱的专用页面。

然而,他们更通用的 Mark Up Your Lists 文档描述了 "Combined" 标记主机特定列表的方法,这允许(粗体强调我的):

When multiple recipes are on a single page, use list page markup that both itemizes the data types and exposes their properties in the item field.

In this case, be sure to include a unique URL for each item, which in this case might include an anchor tag.

因此,如果这也适用于他们的 Recipes rich card,那么在您的情况下,将片段提供为 URL:

可能会奏效
<article id="recipe-1" itemprop="itemListElement" itemscope itemtype="http://schema.org/Recipe http://schema.org/ListItem">
  <link itemprop="url" href="#recipe-1" />
  <!-- … -->
</article>

<article id="recipe-2" itemprop="itemListElement" itemscope itemtype="http://schema.org/Recipe http://schema.org/ListItem">
  <link itemprop="url" href="#recipe-2" />
  <!-- … -->
</article>