手册:$wgNoFollowLinks
解析器: $wgNoFollowLinks | |
---|---|
若设置为true,在维基文本中的外部链接将被赋予rel="nofollow" 属性。 |
|
引进版本: | 1.4.0 (r7174) |
移除版本: | 仍在使用 |
允许的值: | (布尔值) |
默认值: | true |
其他设置: 按首字母排序 | 按功能排序 |
详情
如果设置为true,在维基文本中的外部链接将会被赋予rel="nofollow"
属性,暗示搜索引擎不应该追踪用户提供的链接和垃圾信息的链接,防止影响搜索排名。默认为true。
Setting nofollow for red links
It may be desirable to configure MW to append rel="nofollow"
to internal links that point to pages that haven't yet been written (so-called "red links") for various reasons that include avoiding unnecessary crawler traffic to non-extant pages or for the possibility of improved SEO by avoiding punitive action against a site's ranking due to the presence of "broken links" that aren't broken, just not yet authored.
This may be accomplished by using the HtmlPageLinkRendererEnd
hook as follows:
// Add rel="nofollow" to links to pages that don't exist (redlinks)
$wgHooks['HtmlPageLinkRendererEnd'][] = 'noFollowRedLinks';
function noFollowRedLinks(
$linkRenderer, $target, $isKnown, &$text, &$attribs, &$ret)
{
if (!$isKnown && preg_match('/\bnew\b/S', $attribs['class'] ?? "")) {
$attribs['rel'] = 'nofollow';
}
return true;
}
另请参阅
- $wgNoFollowDomainExceptions
- $wgNoFollowNsExceptions
- Extension:Interwiki - 管理白名单的最简单方式(自从nofollow不适用于跨维基链接时)。
- Manual:nofollow
- meta:nofollow,在元维基上讨论nofollow在维基媒体网站上的使用。有些观点可能也适用于其他维基的决定此配置的设置。