織夢(mèng)dedecms網(wǎng)站的標簽Canonical的寫(xiě)法:
1 |
< link rel = "canonical" href = "http://www.software8.co/" /> |
|
織夢(mèng)DedeCMS首頁(yè)模板的寫(xiě)法:
1 |
< link rel = "canonical" href = "{dede:global.cfg_basehost/}" /> |
|
織夢(mèng)DedeCMS頻道頁(yè)模板的寫(xiě)法:
1 |
< link rel = "canonical" href = "{dede:field.typeurl/}" /> |
織夢(mèng)DedeCMS列表頁(yè)模板的寫(xiě)法:
|
1 |
< link rel = "canonical" href = "{dede:field.typeurl/}" /> |
織夢(mèng)DedeCMS內容頁(yè)模板的寫(xiě)法:
|
1 |
< link rel = "canonical" href = "{dede:field.arcurl/}" /> |
百度宣布支持Canonical標簽,Canonical就是讓我們可以為頁(yè)面定義一個(gè)標準的URL,我們一個(gè)網(wǎng)頁(yè),特別動(dòng)
態(tài)頁(yè)面,因為傳入參數順序的不同,所以會(huì )造成同樣的內容多個(gè)版本的URL,這樣容易被百度認為是重復內容
,甚至有被懲罰的風(fēng)險。 Canonical標簽的出現很好的解決了這個(gè)問(wèn)題,谷歌等其它國外的搜索引擎很早就
支持了Canonical。 但是DedeCMS要想動(dòng)態(tài)輸出一個(gè)標準的URL,也還是需要做一些工作
但是我們會(huì )發(fā)現,當內容分頁(yè)的時(shí)候,分頁(yè)的URL不正確,解決辦法,打開(kāi)/include/arc.archives.class.php 搜索”$TRUEfilename = $this->GetTruePath().$fileFirst."_".$i.".".$this->ShortName;“ 在下面添加一段代碼:
|
1 |
$TRUEfilename = $this ->GetTruePath(). $fileFirst . "_" . $i . "." . $this ->ShortName; |
2 |
GLOBAL $cfg_multi_site ; |
3 |
if ( $cfg_multi_site == 'Y' ) { |
4 |
$this ->Fields[ 'arcurl' ] = $cfg_basehost . $fileFirst . "_" . $i . "." . $this ->ShortName; |
6 |
$this ->Fields[ 'arcurl' ] = $fileFirst . "_" . $i . "." . $this ->ShortName; |
|
頻道頁(yè)的也需要修改代碼,打開(kāi)/include/arc.listview.class.php 搜索”$this->PartView->SetTemplet($tempfile);“,在其上面添加一段代碼:
01 |
if (! file_exists ( $tempfile )) |
03 |
$tempfile = $tmpdir . "/" . $GLOBALS [ 'cfg_df_style' ]. "/index_default.htm" ; |
05 |
GLOBAL $cfg_multi_site , $cfg_basehost ; |
06 |
if ( $cfg_multi_site == 'Y' ) { |
07 |
$this ->PartView->Fields[ 'typeurl' ] = $cfg_basehost .MfTypedir( $this ->Fields[ 'typedir' ]); |
09 |
$this ->PartView->Fields[ 'typeurl' ] = MfTypedir( $this ->Fields[ 'typedir' ]); |
11 |
$this ->PartView->SetTemplet( $tempfile ); |
|
列表頁(yè)的修改有些麻煩,也會(huì )影響到性能,同樣是/include/arc.listview.class.php,搜索“$this->dtp->SaveTo($makeFile);”,在他前面加上一段代碼:
01 |
if ( $this ->PageNo == 1) { |
02 |
$this ->Fields[ 'typeurl' ] = MfTypedir( $this ->Fields[ 'typedir' ]); |
04 |
$this ->Fields[ 'typeurl' ] = $murl ; |
06 |
GLOBAL $cfg_multi_site , $cfg_basehost ; |
07 |
if ( $cfg_multi_site == 'Y' ) { |
08 |
$this ->Fields[ 'typeurl' ] = $cfg_basehost . $this ->Fields[ 'typeurl' ]; |
11 |
$this ->ParseTempletsFirst(); |
12 |
$this ->dtp->SaveTo( $makeFile ); |
|
在修改列表這里的時(shí)候,我們也會(huì )發(fā)現織夢(mèng)DedeCMS的一些問(wèn)題,它列表的首頁(yè)會(huì )有兩份,一份是index.html,一份是list_num_1.html,并且內容是完全一樣的,這對SEO肯定不好,定義Canonical標簽應該能解決這個(gè)問(wèn)題。