用户资料/robots.txt中的用户目录/x-robots-tag 标头

编辑:这原来是一个错误,请参见第 3 楼

如果勾选了“向公众隐藏用户资料”,那么在 robots.txt 中不应该禁止 /u 吗?
否则搜索引擎会遇到 403 错误,这可能会影响排名和可见性。

这据称是在 2014 年实现的 Excluding user profiles in robots.txt (or allow edit of file) - #2 by neil Disallow /users/ in robots.txt · discourse/discourse@8267a45 · GitHub

我能找到的唯一在 robots.txt 中包含 Disallow: /u 的 Discourse 论坛是 Meta আশ্চর্যজনক:

也许 Meta 被定制过,所以跳过了 FIX: Remove /u/ from robots by nattsw · Pull Request #30782 · discourse/discourse · GitHub 中的迁移

干得好,@Moin

目前,我们已经为 /u 路由添加了 noindex。然而,由于 robots.txt 阻止了这一点,搜索引擎无法看到该标头。

然后我们参考了之前的更改 FIX: Always noindex /u routes by nattsw · Pull Request #27712 · discourse/discourse · GitHub

其中提到

其次,SiteSetting.hide_user_profiles_from_public 会引发一个 Forbidden 错误,这阻止了我们的 after_action: add no index header 触发。

此 PR 确保 no index 标头通过 before_action 添加,而不是。我们可能会考虑从 /u 中删除

discourse/app/controllers/robots_txt_controller.rb

2900cbe 中的第 24 行

DISALLOWED_WITH_HEADER_PATHS = %w[/badges /u/ /my /search /tag//l /g /t//.rss /c/.rss]

不幸的是,这并不总是有效。虽然 /u/rgj 确实有一个 x-robots-tag: noindex 标头,但 /u/rgj/summary 没有,所以看起来最近的更改产生了一些不希望的副作用。

(移至 Bug

1 个赞