修改discuz論壇的標題header和foot

1、關於去掉DZ論壇標題處的Powered by Discuz!,去掉他的原因是爲了使標題更加簡潔明瞭,還有就是不被搜索到導致SPAM:具體的修改方法:打開/templates/default/header.htm,在第五行中直接刪除:- Powered by Discuz!就可。

2、如果針對DZ底部的版權信息進行修改,建議不要進行大的修改,那是版權問題,在這裏:風格 模板裏 /templates/default/footer.html 注意對應自己正在使用的模板,第47行處開始。

3、去掉多餘的或修改Meta部分“<meta name="copyright" content="2001-2007 Comsenz Inc." />”同樣在header.htm內。將<meta name="description" content="$metadescription $bbname $seodescription - Discuz! Board" /> 改爲<meta name="description" content="$metadescription $bbname $seodescription" />,

Meta區中這兩個可以留1個即可,是爲了保護作者的版權:<meta name="generator" content="Discuz! $version" />
<meta name="author" content="Discuz! Team and Comsenz UI Team" />

打開archiver/include/header.inc.php,將前面對應的改爲:<title> <?=$_DCACHE['settings']['seotitle']?> <?=$navtitle?> <?=$_DCACHE['settings']['bbname']?> -   Archiver</title>
將Kewords中的Discuz!,Board,Comsenz,forums,bulletin board,去掉,將meta name="description"後邊的 - Discuz! Archiver也可去掉,同樣跟上邊說的一樣,將<meta name="author" content="Discuz! Team & Comsenz UI Team" />
<meta name="copyright" content="2001-2007 Comsenz Inc." /> 其中之一去掉1個。

把關鍵字放大:修改 forum.inc.php,index.inc.php,thread.inc.php
在這些文件的最後加入
<br> <font color=<?=MAINTABLECOLOR?>><?=$_DCACHE['settings']['seokeywords']?></font>

論壇信息分類優化:

打開viewthread.php

查找:

$navigation = "» <a href=\"forumdisplay.php?fid=$fid".($extra ? '&'.preg_replace("/^(&)*/", '', $extra) : '')."\">$forum[name]</a> » $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 = "» <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 = "» <a href=\"forumdisplay.php?fid=$fid".($extra ? '&'.preg_replace("/^(&)*/", '', $extra) : '')."\">$forum[name]</a> » $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 = "» <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";
(奇怪的是6.0的新版本中是$threadurl = "{$boardurl}viewthread.php?tid=$tid$fromuid"; 所以我在這裏沒有改。)改爲
$threadurl = "{$boardurl}viewthread.php?tid=$tid&fromuid=$discuz_uid";
在推薦朋友功能中增加推薦人的標記。這樣的推薦能給推薦人帶來金幣收入。

高級優化?前提:1.discuz! 5.0/5.5 已啓用僞靜態功能,只啓用普通頁面靜態化就可以了;2.不要啓用Archiver功能?;3.後臺的keywords和description設置只是針對首頁的<來源www.gadmin.cn>(如果您沒做列表頁和內容頁的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版本,utf 8 的可能有個別不一樣,請大家繼續尋找相關更適合自己版本的優化內容。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章