Google+分享按钮,包含预览文字+图片

时间:2013-09-25 20:53:26

标签: google-plus schema.org microdata

我尝试在页面中添加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>

enter image description here

2 个答案:

答案 0 :(得分:0)

您可以使用Google Structured Data Testing Tool.调试解析微数据的内容。这可以帮助您了解Google在微观数据注释中看到的内容。

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

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

您的代码段

您使用Google+ Snippet generator了吗?它往往工作得很好。此外,如果您有一个复杂的页面,它可以帮助您使用<header>部分中的元标记开始进行调试。

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

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

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

答案 1 :(得分:0)

它可能是你的g:plus标签上的href属性。而是将其更改为data-href。