3. 每个网页都要有keywords和description这两个meta标签,方便搜索引擎检索。 4. 日期,分类等存档页面都会有和单篇日志内容重复的现象,这回降低文章在搜索引擎中的排名权值,应该告诉爬虫我不希望这些页面被收录。
我拿来主义用他的办法并改进一些细节部分。 1. 标题和Keywords,Description Metab标签的优化: 在<head></head>之间插入
<?php if (is_home())
{
$description = “我的个人网站,记录我想记录的”;
$keywords = “时事、生活、WordPress、Linux”;
}
elseif (is_single())
{
$description = $post->post_title ;
$keywords = “”;
$tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag )
{
$keywords = $keywords . $tag->name . “, “;
}
}
elseif(is_category())
{
$description = category_description($cat);
$keywords = single_cat_title(“”, false);
}
elseif(is_tag())
{
$description = single_tag_title(“”, false);
$keywords = single_tag_title(“”, false);
}
?>
<title><?php if (is_single() || is_page() || is_archive()) { ?><?php wp_title(”,true); ?> @ <?php } bloginfo(‘name’); ?> ( <?php echo $keywords; ?> ) </title>
<meta name=”keywords” content= “<?php echo $keywords; ?>” />
<meta name=”description” content=”<?php echo $description; ?>” />
2. 避免内容没重复检索: 可以修改robots.txt来告诉爬虫那些内容不要收录,但多数情况下,可以在单独的网页html文件中增加相关meta标签来解决这个问题:
<meta name=”robots” content=”index,follow”>
<meta name=”robots” content=”noindex,follow”>
<meta name=”robots” content=”index,nofollow”>
<meta name=”robots” content=”noindex,nofollow”>
其中index标签表示搜索引擎可以收录,noindex不收录;follow表示可以根据页内链接继续漫游,nofollow则禁止。
所以我推荐用via E-Space的办法: 还是在<head></head>之间插入
<?php if (is_single() OR is_page() OR is_home()) : ?><meta name=”robots” content=”index,follow” /><?php else : ?><meta name=”robots” content=”noindex,follow” /><?php endif; ?>
如果不是首页或者单篇文章的内容,就不要收录。