【问题标题】:HTML5 valid Google+ Button - Bad value publisher for attribute relHTML5 有效的 Google+ 按钮 - 属性 rel 的错误值发布者
【发布时间】:2012-04-13 17:08:06
【问题描述】:

我最近将我的网站从 xhtml 过渡到 html5。特别是这样我就可以使用有效的块级锚标签。 <a><div /></a>.

运行验证时遇到以下错误:

元素链接上属性 rel 的错误值发布者:关键字 发布者未注册。

但是根据这个页面,这正是我应该做的。

https://developers.google.com/+/plugins/badge/#connect

我的代码:

<link href="https://plus.google.com/xxxxxxxxxxxxxxxx" rel="publisher" />

<a href="https://plus.google.com/xxxxxxxxxxxxxxx?prsrc=3" style="text-decoration:none;">
  <img src="https://ssl.gstatic.com/images/icons/gplus-16.png" alt="" style="border:0;width:16px;height:16px;"/>
</a>

我不知道如何以符合 html5 的方式实现这一点。有人可以帮忙吗?

【问题讨论】:

  • 你最好去 StackOverflow,因为这是一个编程问题而不是网站管理员问题。
  • @Christopher - 实际上我是故意选择 WM 的,因为它似乎是网站管理员熟悉的东西。如果我错了,我会很感激转会的标志。我在这里的代表太少了。
  • 我认为没有任何整洁的解决方案。 publisher has been dropped 和谷歌代码仍然需要它。我会忽略来自 (validator.nu?) 的错误,并密切关注谷歌文档,看看他们是否更新代码以使用有效的 rel 值(或切换到其他类似 data-publisher 的值)。跨度>

标签: html google-plus-one


【解决方案1】:

1st) &lt;head&gt;内:

<!DOCTYPE html>
<head>
    <!--head code-->
    <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
</head>

2nd) &lt;body&gt; 内的任意位置:

<body>
    <!--body code-->
    <div class="g-plusone" data-size="small" data-annotation="none" data-href="https://plus.google.com/u/1/+StackExchange/"></div>
</body>



此代码有效且与http://validator.w3.org/ 为“朋友”

您可以将 https://plus.google.com/u/1/+StackExchange/ 更改为您想要的任何 google+ 网址 (https://plus.google.com/xxxxxxxxxxxxxxxx/)

Documentation

【讨论】:

    【解决方案2】:

    Google 发送帮助:http://support.google.com/webmasters/bin/answer.py?hl=en&answer=2539557&topic=2371375&ctx=topic

    您需要将?rel=author 添加到您的&lt;a&gt;s href 值并删除不符合要求的&lt;link&gt; 标签:

    <a href="https://plus.google.com/12345?rel=author">
      <img src="https://ssl.gstatic.com/images/icons/gplus-16.png"/>
    </a>
    

    【讨论】:

      【解决方案3】:

      那么,你必须在 head 标签和 body 标签内添加两个链接,如下所示:

      <head>
        <link href='https://plus.google.com/xxxxxxxxxxxxxxxxx' itemprop='publisher'/>
      </head>
      

      之后,在正文中使用 google+ 格式。它应该在body标签下面:

      <body>
      <a href="https://plus.google.com/xxxxxxxxxxxxxxxxx" rel="publisher" />
      .....
      .....
      .....
      </body>
      

      这是屏幕截图。 哎呀!抱歉,我需要 10 声望才能在此页面中加载图片...哈哈 从这两种格式中,我们将通过 Google Webmaster 和 validator.w3.org 的结构化数据进行验证。 如您所知,在微数据模式中使用发布者作为 itemprop 之一,因此,在 body 标签或 html 标签中应该是这样的:

      <body itemscope="" itemtype="http://schema.org/Blog">
      

      *) 当您的网站类型是 BLOG 时就是这样。

      (喜欢这个论坛)tina-andrew-blog 注意:我发现了这个:https://productforums.google.com/d/msg/webmasters/lciIK8HdJXE/kcv8EipRzzcJ 但是,我使用上面的代码,效果很好:(

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-07-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-08
        • 1970-01-01
        • 1970-01-01
        • 2014-06-19
        相关资源
        最近更新 更多