Focus on cloud service provider activities
Notes on website operation and maintenance

Typecho implements the automatic addition of nofollow tags to external links

From the perspective of SEO, we will set nofollow tags on external links to reduce the transmission separation of weights. Here, how can we implement it in the typecho program?

Open the var/HyperDown.php file in the directory of typecho and find the 386 line, such as the following code:

 $text = preg_replace_callback("/\[((?:[^\]]|\\\\\]|\\\\\[)+?)\]\(((?:[^\)]|\\\\\)|\\\\\()+?)\)/", function ($matches) use ($self) { $escaped = $self->parseInline( $self->escapeBracket($matches[1]),  '',  false, false); $url = $self->escapeBracket($matches[2]); $url = $self->cleanUrl($url); return $self->makeHolder("<a href=\"{$url}\">{$escaped}</a>"); }, $text );

Put:

 return $self->makeHolder("<a href=\"{$url}\">{$escaped}</a>");

Replace with:

 if (strstr($url,'//www.laozuo.org') == false ) { return $self->makeHolder("<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$escaped}</a>"); } else { return $self->makeHolder("<a href=\"{$url}\" target=\"_blank\">{$escaped}</a>"); }

 

Vote for you
Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » Typecho implements the automatic addition of nofollow tags to external links