张建群:DZ论坛优化方法

  • A+
所属分类:SEO技巧

第一步,修改论坛风格的temlpates/风格/hearder.htm(这里是指你所用的风格的,如果你有20个风格,最好改20次)

找到:

<title>$navtitle $bbname $seotitle - Powered by Discuz!</title>

替换成:

<title>$navtitle $bbname $seotitle</title>

找到:

<meta name="keywords" content="Discuz!,Board,Comsenz,forums,bulletin board,$seokeywords">

<meta name="description" content="$bbname $seodescription - Discuz! Board">

修改为:

<meta name="keywords" content="$navtitle,$seokeywords">

<meta name="description" content=" $navtitle $bbname $seodescription">

第二步,修改完善 archiver

archiver在论坛中,就是像外交大臣一样的地位,可以使你的论坛更容易被搜索到。打开archiver/include/header.inc.php

查找:

<title> <?=$_DCACHE['settings']['seotitle']?> <?=$navtitle?> <?=$_DCACHE['settings']['bbname']?> - powered by Discuz! Archiver</title>

替换成:

<title> <?=$_DCACHE['settings']['seotitle']?> <?=$navtitle?> <?=$_DCACHE['settings']['bbname']?> -   Archiver</title>

找到:

<meta name="keywords" content="Discuz!,Board,Comsenz,forums,bulletin board,<?=$_DCACHE['settings']['seokeywords']?>">

<meta name="description" content="<?=$_DCACHE['settings']['bbname']?> <?=$_DCACHE['settings']['seodescription']?> - Discuz! Archiver">

修改为:

<meta name="keywords" content="<?=$navtitle?>,<?=$_DCACHE['settings']['seokeywords']?>">

<meta name="description" content="<?=$_DCACHE['settings']['bbname']?> <?=$_DCACHE['settings']['seodescription']?>">

把关键字无限放大

修改 forum.inc.php,index.inc.php,thread.inc.php

在这些文件的最后加入

<br>

<font color=<?=MAINTABLECOLOR?>><?=$_DCACHE['settings']['seokeywords']?></font>

第三步,论坛信息分类优化

打开viewthread.php

查找:

$navigation = "&raquo; <a href=\"forumdisplay.php?fid=$fid".($extra ? '&'.preg_replace("/^(&)*/", '', $extra) : '')."\">$forum[name]</a> &raquo; $thread[subject]";

$navtitle = $thread['subject'].' - '.strip_tags($forum['name']);

if($forum['type'] == 'sub') {

       $query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE fid='$forum[fup]'");

       $fup = $db->fetch_array($query);

       $navigation = "&raquo; <a href=\"forumdisplay.php?fid=$fup[fid]\">$fup[name]</a> $navigation";

       $navtitle = $navtitle.' - '.strip_tags($fup['name']);

}

$navtitle .= ' - ';

替换成:

if($lastvisit < $thread['lastpost'] && (!isset($_DCOOKIE['fid'.$fid]) || $thread['lastpost'] > $_DCOOKIE['fid'.$fid])) {

       dsetcookie('fid'.$fid, $thread['lastpost'], 3600);

}

$navigation = "&raquo; <a href=\"forumdisplay.php?fid=$fid".($extra ? '&'.preg_replace("/^(&)*/", '', $extra) : '')."\">$forum[name]</a> &raquo; $thread[subject]";

if($thread['typeid'] && isset($forum['threadtypes']['types'][$thread['typeid']])) {

$navtitle = '('.$forum['threadtypes']['types'][$thread['typeid']].')'.$thread['subject'].' - '.strip_tags($forum['name']);

}else{

$navtitle = $thread['subject'].' - '.strip_tags($forum['name']);

}

if($forum['type'] == 'sub') {

       $query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE fid='$forum[fup]'");

       $fup = $db->fetch_array($query);

       $navigation = "&raquo; <a href=\"forumdisplay.php?fid=$fup[fid]\">$fup[name]</a> $navigation";

       $navtitle = $navtitle.' - '.strip_tags($fup['name']);

}

$navtitle .= ' - ';

第四步,用googleSitemap 和 雅虎url工具优化论坛,完成!

在misc.php中找到

$threadurl = "{$boardurl}viewthread.php?tid=$tid";

改为

$threadurl = "{$boardurl}viewthread.php?tid=$tid&fromuid=$discuz_uid";

在推荐朋友功能中增加推荐人的标记。这样的推荐能给推荐人带来金币收入。

高级优化。前提:1.discuz! 5.0/5.5 已启用伪静态功能,只启用普通页面静态化就可以了;2.不要启用 Archiver功能;3.后台的keywords和description设置只是针对首页的(如果您没做列表页和内容页的meta修改则也应用到它们);4.后台首页文件名为/(当然您也可以设置自己特定的),然后开始优化:

一、meta的优化

discuz的后台可以对meta信息进行设置,甚至可以添加自己的头部信息,但它的设置都是针对于所有页面的,全部页面都拥有相同的keywords和description是SEO所不赞成的。

方案一:删除meta

修改页头模板文件 templates/default/header.htm:将meta的keywords和description标签删除。

这两个标签作用很小了,而且还有discuz自带的一些无用信息,用得不好反而会有坏作用,因此宁缺勿滥。

方案二:定制meta

本部分实现了将内容页keywords设为帖子标题,description为内容前100字;也实现了主页与各版列表页meta的单独设置(不同版的不同,同一版各列表页相同)。

1.修改页头模板文件 templates\default\header.htm:将meta的keywords和description标签改为如下形式

<meta name="keywords" content="{$metakeywords}$seokeywords" />

<meta name="description" content="$seodescription" />

这里的$seokeywords、$seodescription就是后台设置的那个值,下面说怎么定制这个值;{$metakeywords}是奇虎的关键字,留下以后处理

2.内容页(viewthread)设置keywords为帖子标题,description为内容前100字

2.1修改 viewthread.php 文件:

在 include template('viewthread'); (更新:dz5.5为iinclude template($iscircle ? 'supesite_viewthread' : 'viewthread'); ) 语句的上面加入一行:

require_once DISCUZ_ROOT.'./include/bmt.thread.inc.php';

2.2创建 include/bmt.thread.inc.php 文件,内容为

<?php

if(!defined('IN_DISCUZ')) { exit('Access Denied'); }

$seokeywords = strip_tags($thread['subject']); //关键字设为帖子的标题

//(已更新: nethome 提出问题,当启用主题分类并允许按类别浏览时,原来代码会有问题。所以加了标签过滤,本来在viewthread.php中改更好,为以后升级方便,还是放在这里吧,subject很短,不会影响效率)

$seodescription = current( $postlist );//description取文章内容的前100字

$seodescription = mb_substr( $seodescription['message'],0,100,"gb2312" );

$seodescription = htmlspecialchars( strip_tags($seodescription) );

?>

*此处数字和个别函数适用于GBK版本

编辑:沈阳seo 剑歌

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin

发表评论取消回复

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:10   其中:访客  9   博主  1

    • 精品软件 精品软件 2

      呵呵 论坛没搞过 文章技术性较高

      • 学夫子 学夫子 0

        现在都已经是腾讯的了,呵呵,基本上都离不开这公司的

        • 路过的卡卡西 路过的卡卡西 3

          不是自己写的吧~

          • 路过的卡卡西 路过的卡卡西 3

            想起来了,。Dz的帖子

              • 剑歌 剑歌 Admin

                @路过的卡卡西 不是自己写的 DZ的帖子 有时间加我QQ交流下

              • WordPress啦 WordPress啦 0

                我还没发过几次文章呢

                • cheap coach purses cheap coach purses 1

                  我也来凑凑热闹,,来a>踩踩,记得回访哦

                  • cheap coach purses cheap coach purses 1

                    coach bags on sale相互踩踩,记得回访哦,記得互踩哦,朋友

                    • cheap coach purses cheap coach purses 1

                      朋友,我来buy coach bags给你踩踩,记得回访哦,互踩哦,朋友

                      • 汽车保险费用计算 汽车保险费用计算 1

                        这个我也折腾了好长时间 结果还是没有弄透

                        产品是好 不过处理起来也挺麻烦的