rel="category tag" 的使用与思考

在网站优化中,对于a标签的优化可以增加rel属性,例如WordPress的分类链接标签是加上了 rel="category tag"。rel 属性还有更多的应用,之前我在WordPress 友情链接增加 external nofollow,这也是一种优化方法。下面说说对于 rel="category tag"的使用。

是否使用rel=”category tag”

Denis 童鞋写的“解决 rel="category tag" 问题以便通过 W3C 验证”值得参考和使用,我在思考去掉 rel="category tag" 我们还不如去优化 rel="category tag"。

WordPress rel="category tag" 优化

rel="category tag" 没有得到 W3C 的 HTML5 验证器的认可,那么我们不去掉,换个W3C认可的:rel="archive"。

add_filter( 'the_category', 'wpjam_fix_catgory_rel' );

function wpjam_fix_catgory_rel ( $text ) {
	$text = str_replace('rel="category tag"', 'rel="archive"', $text);
	return $text;
}

将以上代码放到主题文件functions.php中即可,我已经在博客上启用,大家可以查看下文章标题下面的分类a标签中的rel属性。

关于rel="archive"的一些参考资料:

The referenced document is a list of previously created versions of related documents, such as the archives of a blog.


©我爱水煮鱼,本站推荐使用的主机:阿里云,国外主机建议使用BlueHost

本站长期承接 WordPress 优化建站业务,请联系微信:「chenduopapa」。