讨论区架构改进

请保留 URL,即使它被阻止了。您可以讨论这对于您的论坛用例是否有意义,但即使爬虫被阻止,它也有助于消除歧义。

6 个赞

这仍然只是一个礼貌的请求,甚至谷歌也不是每次都遵守。例如,Gmail 中的链接会让 Googlebot 立即访问,足够的访问量会导致索引和搜索结果。

另外……我们/你不知道将来情况会如何变化。如果现在解决了,那么以后就无需担心了。当然,这需要工作时间,但投入时间和讨论它也需要工作时间 :smirking_face:

1 个赞

现在 DiscussionForumPosting第一页 上的 datePublished 属性与 第二页及之后 上的 datePublished 不同

  • 第一页:
    2015-07-05T22:02:58Z
  • 第二页及之后:
    2015-07-05T22:02:57Z

我认为 Google 不会信任不同的数据,因此可能会认为这两个 URL 包含不同的 DiscussionForumPosting,无法合并。

最好在 第一页第二页及之后 上使用相同的数据源。
例如,始终使用来自主题datePublished,而不是来自第一条帖子

search.google.com/test/rich-results for first page
datePublished: 2015-07-05T22:02:58Z

search.google.com/test/rich-results for page=2
datePublished: 2015-07-05T22:02:57Z


PR:

始终使用来自主题的 datePublished,而不是来自 first_post。这可确保 datePublished第一页第二页及之后 保持一致。

无需在 第二页及之后 重复 text。特别是当 text 仅为摘要且与 第一页 上的 text 不完全一致时,请勿在 第二页及之后 设置 text
Google Search Console 中的意外结果:在后续页面 第二页及之后 保留 text 属性。

3 个赞

隐藏“几天前关闭”帖子,使其不被爬虫视图抓取

如果一个主题被关闭,会有一个特殊的帖子添加到该主题中:
例如,请参阅 Google structured data for forums and profile pages - #15

当然,这个帖子没有有一个空的 text 属性。请参阅 validator.schema.org …/t/-/286762 → 最后的评论:

Google Search Console 中的报告

结论

因此,这种特殊的系统/公告帖子应该从爬虫视图中排除。

PR

这种特殊的系统/公告帖子已从爬虫视图中排除,因为它们没有任何内容。

空内容会在 Google Search Console 中触发一个非关键性问题“缺少字段‘text’(在‘comment’中)”。

当可用时,将作者姓名元数据设置为全名配置文件字段是否更有意义?至少在禁用了“在用户体验中优先显示用户名”的论坛上(但我认为无论如何,URL 字段都可以消除歧义)。

有什么办法可以解决这个问题,还是必须由 Discourse 团队更新核心?

@rrlevering 关于这个“后续页面不需要 text 属性”/ IsExternalContent() 检查:

我在实际域名上有一个测试用例:

Discourse 实现的 DiscussionForumPosting 在…

  • 第一页 - 页面 URL:https://example.org/t/-/12345
    • 属性 urlhttps://example.org/t/-/12345
    • 属性 text– 已设置 –
    • 属性 author:– 已设置 –
  • page=2 - 页面 URL:https://example.org/t/-/12345?page=2
    • 属性 urlhttps://example.org/t/-/12345
    • 属性 text– 完全未设置 –
    • 属性 author:– 已设置 –

结果:Google Search Console(实时测试)

  • 第一页
    DiscussionForumPosting 有效
  • page=2
    DiscussionForumPosting 无效
    • 1 个严重问题应指定“text”、“image”或“video”中的一个

所以,要么这里没有对 IsExternalContent() 的检查,要么该检查假设以下情况下的 page URL 等于属性 url

  • 页面 URL:
    https://example.org/t/-/12345?page=2
  • 属性 url
    https://example.org/t/-/12345

因此,目前我们必须在后续页面上重复 text 属性才能在 Google Search Console 中获得一个有效DiscussionForumPosting

DiscussionForumPosting 的架构标记无效 - 仅限特定主题/帖子的网址

受影响的主题: 总帖子数超过 20 个的主题
受影响的网址: …/t/-/NNN/7…/t/-/NNN/20

“Google 结构化数据测试工具”中的报告

网址 …/t/-/NNN/11:具有不同总帖子数的主题(点击打开)

– 所有示例主题均已“关闭”,以确保帖子总数不会改变。此错误也会影响“开放”主题!–

网址 …/t/-/16968/1 至 …/t/-/16968/38:一个当前有 38 个帖子的主题(点击打开)

有效的架构标记:
DiscussionForumPosting 本身仍然有一个不必要的属性 position: 1。–

无效的架构标记: 缺少 author/datePublished

再次有效的架构标记:(此处:@page > 1true):

技术考量

1. `@topic_view.prev_page` 可能不是决定是否显示 `author`/`datePublished` 的最佳解决方案。

app/views/topics/show.html.erb#L53-L60

      <% if @topic_view.prev_page %>
        <meta itemprop='datePublished' content='<%= @topic_view.topic.created_at.to_formatted_s(:iso8601) %>'>
        <span itemprop='author' itemscope itemtype="http://schema.org/Person">
          <meta itemprop='name' content='<%= @topic_view.topic.user.username %>'>
          <link itemprop='url' href='<%= Discourse.base_url %>/u/<%= @topic_view.topic.user.username %>'>
        </span>
        <meta itemprop='text' content='<%= @topic_view.topic.excerpt %>'>
      <% end %>
2. `@topic_view.prev_page` 的实现本身可能存在错误。

lib/topic_view.rb#L113-L115
lib/topic_view.rb#L128-L130
lib/topic_view.rb#L193-L195

    @post_number = [@post_number.to_i, 1].max
# ---
    @page = @page.to_i > 1 ? @page.to_i : calculate_page
# ---
  def prev_page
    @page > 1 && posts.size > 0 ? @page - 1 : nil
  end

这里有错误吗?
lib/topic_view.rb#L751-L755

  def calculate_page
    posts_count =
      is_mega_topic? ? @post_number : unfiltered_posts.where("post_number <= ?", @post_number).count
    ((posts_count - 1) / @limit) + 1
  end
  • calculate_page 是否可能产生意外结果,因为它使用了当前的 @post_number 并且在 7 到 20 的值时似乎失败了?
  • ((posts_count - 1) / @limit) + 1 的结果是:
    ((7 - 1) / 20) + 1 = 1.3 = 1
  • 预期的页码是多少?也许使用非整数值进行计算,然后通过 floor/ceil 将数字四舍五入,并转换为整数:
    (((posts_count - 1.0) / (@limit + 0.0)) + 1.0).floor.to_i
  • 也许检查 unfiltered_posts.where("post_number <= ?", @post_number),因为 @topic.posts 可能不包含所有帖子,从 post_1 开始,正如预期的那样。

lib/topic_view.rb#L53-L55
lib/topic_view.rb#L119-L127
lib/topic_view.rb#L835-L841

  def self.chunk_size
    20
  end
# ---
    @chunk_size =
      case
      when @print
        TopicView.print_chunk_size
      else
        TopicView.chunk_size
      end

    @limit ||= @chunk_size
# ---
  def unfiltered_posts
    result = filter_post_types(@topic.posts)
    result = result.with_deleted if @guardian.can_see_deleted_posts?(@topic.category)
    result = result.where("user_id IS NOT NULL") if @exclude_deleted_users
    result = result.where(hidden: false) if @exclude_hidden
    result
  end

结论

在此边缘情况下…

  • 总帖子数超过 20 个的主题
  • …/t/-/NNN/7…/t/-/NNN/20

…第一个帖子不属于当前视图,并且由于视图仍在第一页,因此 @topic_view.prev_page 未触发。

因此,DiscussionForumPosting 微数据架构的所有仅在第一个帖子上下文或 @topic_view.prev_page == true 的情况下渲染的属性都丢失了。

PR

DiscussionForumPosting 微数据架构的某些属性在第一个帖子的上下文中渲染。请确保在第一个帖子不属于当前视图的情况下也设置这些属性。

3 个赞

嗯……这出乎意料。很抱歉给您带来麻烦,我认为该URL比较检查在比较时会丢弃查询参数。我将推出修复程序。

3 个赞

这里有关于这个修复的任何更新吗?

我相信本周推出的修复程序会在“这是一个外部网址吗?”检查中考虑查询参数。因此,论坛通过查询参数(foo 与 foo?page=2)引用不同网址的 OP 时,GSC 不会报告错误。

3 个赞

相信本周推出的修复程序会在“这是外部网址吗”检查中考虑查询参数

@rrlevering 在另一个论坛平台,您建议在线程的每个帖子中嵌套 comment - Schema.org Property schema。Discourse 似乎没有这样做。您仍然推荐这样做吗?

Discourse 会为线程中的每个帖子嵌套 Comment schema。请查看 Schema Markup Validator DiscussionForumPosting 对象,查看嵌套的评论。

2 个赞

谢谢!我把它漏掉了,它嵌套在 DiscussionForumPosting 中。