f
wordpress新站高度集中权重seo优化方案
wordpress新站高度集中权重seo优化方案
二呆 7年前 (2017-09-13) wordpress优化  #wordpress# 
浏览:4996

引言:此文由子域名转移而来,因为细微强迫症和放弃子域名而不舍得完全丢弃,所以将会逐步第二次转移文章到主域名上来,二者主题(阿里白秀和D8)均来自大前端,追求完美的同时有一丝小懒,主题就不换了,D8主题用起来挺好。

说起seo优化,我们以百度seo优化为主,百度旗下百度知道的seo做的非常好,权重非常之高,在众多站长之中百度知道是发外链的大型宣传平台,但百度知道如此高权重是如何做到的呢?下面来看下canonical标签。

方案一(canonical篇):

  1. <link rel="canonical" href="http://zhidao.baidu.com/daily/view?id=810" />

canonical标签有什么作用?

对一组内容完全相同或高度相似的网页,通过使用canonical标签可以告诉搜索引擎哪个页面为规范的网页,能够规范网址并避免搜索结果中出现多个内容相同或相似的页面,帮助解决重复内容的收录问题,避免网站相同内容网页的重复展示及权重的分散,提升规范网页的权重,优化规范网页的排名。

那怎么在wordpress网站中使用canonical标签呢?方法如下:

⑴在functions.php文件中添加分类目录分页链接获取函数,代码如下:

  1. function tongleer_archive_link( $paged = true ) {
  2.         $link = false;
  3.         if ( is_front_page() ) {
  4.                 $link = home_url( '/' );
  5.         } else if ( is_home() && "page" == get_option('show_on_front') ) {
  6.                 $link = get_permalink( get_option( 'page_for_posts' ) );
  7.         } else if ( is_tax() || is_tag() || is_category() ) {
  8.                 $term = get_queried_object();
  9.                 $link = get_term_link( $term$term->taxonomy );
  10.         } else if ( is_post_type_archive() ) {
  11.                 $link = get_post_type_archive_link( get_post_type() );
  12.         } else if ( is_author() ) {
  13.                 $link = get_author_posts_url( get_query_var('author'), get_query_var('author_name') );
  14.         } else if ( is_archive() ) {
  15.                 if ( is_date() ) {
  16.                         if ( is_day() ) {
  17.                                 $link = get_day_link( get_query_var('year'), get_query_var('monthnum'), get_query_var('day') );
  18.                         } else if ( is_month() ) {
  19.                                 $link = get_month_link( get_query_var('year'), get_query_var('monthnum') );
  20.                         } else if ( is_year() ) {
  21.                                 $link = get_year_link( get_query_var('year') );
  22.                         }
  23.                 }
  24.         }
  25.         if ( $paged && $link && get_query_var('paged') > 1 ) {
  26.                 global $wp_rewrite;
  27.                 if ( !$wp_rewrite->using_permalinks() ) {
  28.                         $link = add_query_arg( 'paged', get_query_var('paged'), $link );
  29.                 } else {
  30.                         $link = user_trailingslashit( trailingslashit( $link ) . trailingslashit( $wp_rewrite->pagination_base ) . get_query_var('paged'), 'archive' );
  31.                 }
  32.         }
  33.         return $link;
  34. }

⑵在header.php中插入如下代码:

  1. <?php
  2. if(is_home()) { ?>
  3. <link rel="canonical" href="<?php echo tongleer_archive_link();?>"/>
  4. <?php } ?>
  5. <?php
  6. if(is_category()) { ?>
  7. <link rel="canonical" href="<?php echo tongleer_archive_link();?>"/>
  8. <?php } ?>
  9. <?php
  10. if(is_single())  { ?>
  11. <link rel="canonical" href="<?php the_permalink(); ?>"/>
  12. <?php }?>
  13. <?php
  14. if(is_tag()) { ?>
  15. <link rel="canonical" href="<?php echo tongleer_archive_link();?>"/>
  16. <?php }?>

这样就实现了在wordpress网站上添加了canonical标签,集中网站权重。

方案二(robots篇):

同样在百度知道中也会发现robots标签:

  1. <meta name="robots" content="noindex,follow" />

因此robots标签集中权重的方法如下:

⑴在function.php中添加如下代码:

  1. //阅读更多链接添加nofollow
  2. add_filter('the_content_more_link','add_nofollow_to_link', 0);
  3. function add_nofollow_to_link($link) {
  4. return str_replace('<a', '<a rel="nofollow"', $link);
  5. }
  6. //标签云添加nofollow
  7. add_filter('wp_tag_cloud', 'cis_nofollow_tag_cloud');
  8. function cis_nofollow_tag_cloud($text) {
  9.     return str_replace('<a href=', '<a rel="nofollow" href=',$text);
  10. }
  11. //内容页tag链接添加nofollow
  12. add_filter('the_tags', 'cis_nofollow_the_tag');
  13. function cis_nofollow_the_tag($text) {
  14.     return str_replace('rel="tag"', 'rel="tag nofollow"', $text);
  15. }
  16. //作者归档链接添加nofollow
  17. add_filter('the_author_posts_link', 'cis_nofollow_the_author_posts_link');
  18. function cis_nofollow_the_author_posts_link ($link) {
  19. return str_replace('</a><a href=', '<a rel="nofollow" href=',$link);
  20. }
  21. //访客评论链接添加nofollow
  22. add_filter('comments_popup_link_attributes', 'cis_nofollow_comments_popup_link_attributes');
  23. function cis_nofollow_comments_popup_link_attributes () {
  24. echo 'rel="nofollow"';
  25. }

⑵在header.php中加入如下代码:

  1. <?php
  2. if(is_home()) { ?>
  3. <?php $paged = get_query_var('paged');
  4. if ( $paged > 1 ) echo'<meta name="robots" content="noindex,follow" />'; ?>
  5. <?php } ?>
  6. <?php
  7. if(is_category()) { ?>
  8. <?php $paged = get_query_var('paged');
  9. if ( $paged > 1 ) echo'<meta name="robots" content="noindex,follow" />'; ?>
  10. <?php } ?>
  11. <?php
  12. if(is_tag()) { ?>
  13. <?php $paged = get_query_var('paged');
  14. if ( $paged > 1 ) echo'<meta name="robots" content="noindex,follow" />'; ?>
  15. <?php }?>

到这里,通过wordpress新站高度集中权重seo优化的两种方案,便可集中网站权重,防止没有实质性内容被搜索引擎所收录,快来加到你的网站中把。

推荐阅读
  • 以下仅供学习使用以及纪念之用,已过时,将不再继续鼓捣,请知悉。因能力有限,将它们弄出来后修改时都得调试半天,日后随缘上香。任何事物的成长都需要沉淀,不然就会成以下这些一样的结果。继续在另一个条漫长的转型不归路上走着…走着……以下仍然可以站内搜索相关简介:001、DNSP...
  • 插件截图:插件简介:TleUCenterForWordpress是一个用户中心插件,放置于前台网页的左下角,供用户登陆/管理只用,使用邮箱验证码登陆,登陆之后在使用TleWeiboForWordPressV2.0微博主题的情况下,可以显示微博列表、文章列表、评论列表,也可...
  • 插件截图:插件介绍:TleLiveCtrlForWordpress是一个基于Kplayer的直播遥控器插件,也可以叫做KplayerForWordPress插件,支持多平台直播推流,进行积分点播、查询、跳过等功能,支持Payjs微信、支付宝支付,是一个可以24小时直播推流的...
  • 主题截图:主题简介:一款Wordpress版本的TleWeiboForWordPress电脑/手机版微博主题使用方法:将本主题里的所有文件放在您网站目录的wp-content/themes内,注意文件夹名字必须为TleWeibo或TleWeiboWap。...
  • 插件简介:即时聊天插件为WordPress站长及用户提供即时聊天功能,前台环信即时聊天需要配合个人中心插件,暂不支持手机端。在支持手机端的路上,因为万恶的360网站卫士最近访问困难,导致停留了N久,最后啥也没动,就升级至V1.0.10了,不过仅仅支持了简单的手机端版本。使...

o p
Ú
>