首页 » WordPress » 我是如何 SEO WordPress 的 2:Description 和 Keywords

我是如何 SEO WordPress 的 2:Description 和 Keywords

November 16th, 2008 Denis

Description 和 Keywords 的重要性已经不像以前那么重要了,但是设置正确的 Description 和 Keywords 还是对你的排名有利。

WordPress 在撰写日志的时候,可以给日志添加摘要(excerpt)和标签(tag),我的做法就是,就如给日志添加了摘要就把摘要做为 Description,如果没有设置摘要的话,则截取文章的前 220 个字作为 Description,而标签直接作为 Keywords。代码如下:

<?if (is_home()){
    $description = "我爱水煮鱼是一个关注 WordPress 开源博客平台应用和互联网的 IT 博客。";
    $keywords = "WordPress, 博客, 互联网, 主题, 插件";
} elseif (is_single()){
    if ($post->post_excerpt) {
        $description     = $post->post_excerpt;
    } else {
        $description = substr(strip_tags($post->post_content),0,220);
    }
 
    $keywords = "";       
    $tags = wp_get_post_tags($post->ID);
    foreach ($tags as $tag ) {
        $keywords = $keywords . $tag->name . ", ";
    }
}
?>
<meta name="keywords" content="<?=$keywords?>" />
<meta name="description" content="<?=$description?>" />

上面代码请放到 header.php 相应的位置,同样我也只优化了首页和日志页面。

作者:Denis
原文链接:我是如何 SEO WordPress 的 2:Description 和 Keywords

标签:

分享到 Twitter 分享到 Twitter Delicious 收藏到 Delicious 分享到 Google Reader 分享到 Google Reader 分享到 FriendFeed 分享到 FriendFeed

53 条评论 添加你的评论

发表评论

你必须 登陆 之后才能留言。你可以使用以下方式快速登陆我爱水煮鱼:

你也可选择直接在本站 注册


Google 发布两款 Discuz! 论坛插件:谷歌看图和谷歌贴图 对话 NeoEase


赞助商

 (mt) Media Temple 长期承接 WordPress 项目 WordPress主机合租 用网页模板,当然要选TemplateMonster China 免費資源網路社群 freegroup.org http://p6p9.com/ 在我爱水煮鱼投放广告位

本站推荐

快速导航