修复Blogger中的结构化数据仇恨错误

时间:2018-10-02 21:03:25

标签: xml blogger

我的博客中有此代码

1。

<b:includable id='postAuthor' var='post'>
          <!-- Post Author -->
          <b:if cond='data:allBylineItems.author'>
            <span class='post-author'><em><data:allBylineItems.author.label/></em> <a expr:href='data:post.author.profileUrl' expr:title='data:post.author.name' target='_blank'><data:post.author.name/></a></span>
          </b:if>
        </b:includable>

2。

          <div class='post-meta'>
        <span class='post-author'><em><data:widgets.Blog.first.allBylineItems.author.label/></em> <a expr:href='data:post.author.profileUrl' expr:title='data:post.author.name' target='_blank'><data:post.author.name/></a></span> <span class='post-date published' expr:datetime='data:post.date.iso8601'><em><data:widgets.Blog.first.allBylineItems.timestamp.label/></em> <span class='updated'><data:post.date/></span></span>
      </div>

但是google显示,结构化数据中缺少作者。

如何在Blogger中修复作者缺失字段?

2 个答案:

答案 0 :(得分:0)

您的代码中缺少一些部分

应该是这样

<b:includable id='postAuthor' var='post'>
  <!-- Post Author -->
  <b:if cond='data:widgets.Blog.first.allBylineItems'>
    <span class='post-author'>
        <em><data:widgets.Blog.first.allBylineItems.author.label/></em>
        <a expr:href='data:post.author.profileUrl' expr:title='data:post.author.name' target='_blank'>
            <data:post.author.name/>
        </a>
    </span>
  </b:if>
</b:includable>

答案 1 :(得分:0)

请查看以下嵌入作者的示例。

    <b:includable id='postAuthor'>
      <span class='byline post-author vcard'>
        <span class='post-author-label'>
          <data:byline.label/>
        </span>
        <span class='fn'>
          <b:if cond='data:post.author.profileUrl'>
            <meta expr:content='data:post.author.profileUrl'/>
            <a class='g-profile'
               expr:href='data:post.author.profileUrl'
               rel='author'
               title='author profile'>
              <span><data:post.author.name/></span>
            </a>
          <b:else/>
            <span><data:post.author.name/></span>
          </b:if>
        </span>
      </span>
    </b:includable>   

    <b:loop values='data:posts' var='post'>
  <b:loop values='data:widgets.Blog.first.allBylineItems where (i => i.name == "author")' var='byline'>

    <b:include name='postAuthor'/>

  </b:loop>
</b:loop>

    <b:includable id='headerByline'>
          <b:if cond='data:view.isSingleItem and data:widget.type == "Blog"'>
            <b:include name='super.headerByline'/>
          <b:else/>
            <b:include data='{ items: ["author", "timestamp"] }' name='headerBylineOverride'/>
          </b:if>
        </b:includable>