1

我尝试将 Google+ 按钮添加到我的页面。按钮本身有效,但文本和图像始终为空。我用 schema.org 标签注释了我的身体和一些元素,但它不起作用。我在这里做错了什么?

<body itemscope itemtype="http://schema.org/Article"> 
    <div itemprop="name">This is the article name</div>
    <img itemprop="image" src="thumbnail.jpg" />
    <p itemprop="description">This is the description of the article.</p>

     <g:plus action="share" href="testUrl"></g:plus>

    <script type="text/javascript">
      window.___gcfg = {
        lang: 'en-US'
      };

      (function() {
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = 'https://apis.google.com/js/plusone.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
      })();
    </script>

</body>

在此处输入图像描述

4

2 回答 2

0

它可能是 g:plus 标记上的 href 属性。相反,将其更改为 data-href。

于 2013-12-04T21:14:45.827 回答
0

您可以使用Google 结构化数据测试工具调试正在解析的微数据。这可以帮助您了解 Google 在您的微数据注释中看到的内容。

尝试从您的分享/+1 中删除该 URL。目标网址将回退到当前页面,我假设您希望人们分享。

如果这不是问题,还有一些其他的事情可能会有所帮助:

你的片段:

您是否使用过Google+ 代码段生成器?它往往工作得很好。此外,如果您有一个复杂的页面,它可以帮助使用该<header>部分中的元标记开始调试。

代理: 这让我想到了下一点,如果有代理阻止您的页面或阻止人们访问它的安全性,这将阻止共享预览渲染器。确保您的页面(共享目标)可公开访问。

另一种可能性:如果您的页面缓存在服务器的代理中,这将阻止页面被共享预览渲染器更新。

如果您将锚链接或查询字符串添加到 url 的末尾,例如 foo.com/index.html vs foo.com/index.html#test vs foo.com/index.html?test=yes 它应该确保将包括一个没有微数据的缓存版本。

于 2013-09-25T21:50:17.967 回答