我的网站上有太多传出链接。我想为谷歌制作它们no index
。我不想写rel="no index"
每个链接...
(< a href="..." rel="noindex, nofollow" >...< /a > )
我可以创建一个class
并用css写这个吗?
接着
<div class="noindexlinks">
这可能吗?或者我可以为此编辑我的 htaccess 吗?
您不能通过 分配html
属性css
。
但是,您可以使用任意css
类和一些jQuery
.
首先,创建一个任意类,比如no_follow_links
将此类分配给各种<a>
标签,例如,<a class="no_follow_links" href="http://address.com">
NOINDEX
是一个元标签,你正在寻找nofollow
你的<a>
标签。
$(".no_follow_links").each(function(){
$(this).attr("rel","nofollow");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a class="no_follow_links" href="http://google.com">Link</a>
<a class="no_follow_links" href="http://bing.com">Link</a>
<a class="no_follow_links" href="http://yahoo.com">Link</a>