sitemap是網站上各網頁的清單。建立并送出sitemap有助于百度(Google)發現并了解您網站上的所有網頁,包括百度通過傳統抓取方式可能找不到的網頁。還可以使用sitemap提供有關你網站的其他資訊,如上次更新日期、sitemap檔案的更新頻率等,供百度 (Google)spider參考。
百度(Google)對已送出的資料,不保證一定會抓取及索引所有網址。但是,百度(Google)會使用sitemap中的資料來了解網站的結構等資訊,這樣可以幫助百度改進抓取政策,并在日後能更好地對網站進行抓取。此外,sitemap與搜尋排名沒有關系。
一.織夢DEDECMS sitemap.html的制作
這裡我們用織夢自帶的标簽生成
但是生成的路徑是在/data目錄下,我們一般放在根目錄下,是以更改一下檔案:
方法如下:
第一步:打開/dede/makehtml_map.php
if($dopost=="site")
{
$murl = $cfg_cmspath."/data/sitemap.html"; //内容來自織夢模闆團
$tmpfile = $cfg_basedir.$cfg_templets_dir."/plus/sitemap.htm";
}
更改成為
if($dopost=="site")
{
$murl = $cfg_cmspath."/sitemap.html";
$tmpfile = $cfg_basedir.$cfg_templets_dir."/plus/sitemap.htm";
}
這樣就實作了sitemap.html放在根目錄的的任務了
Sitemap的模闆檔案是\templets\plus\sitemap.htm,通過修改可以定義樣式
二.織夢DEDECMS sitemap.xml的制作
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<url>
<loc>{dede:global.cfg_basehost/}</loc>
<lastmod>{dede:arclist row=1 titlelen=24 orderby=pubdate}
[field:pubdate function=strftime('%Y-%m-%d',@me)/]
{/dede:arclist}</lastmod>
<changefreq>always</changefreq>
<priority>1.0</priority>
</url>
{dede:channel row='1000' type='top'}
<url>
<loc>[field:typelink /]</loc>
<changefreq>daily</changefreq>
<priority>0.9</priority>
</url>
{/dede:channel}
{dede:arclist row=2000 orderby=pubdate}
<url>
<loc>[field:arcurl/]</loc>
<lastmod>[field:pubdate function=strftime('%Y-%m-%d',@me)/]</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
{/dede:arclist}
</urlset>
将上面這個檔案儲存成一個模闆檔案如gsitemap.htm,放在模闆目錄下如templets/plus下
然後織夢背景操作
裡增加一個清單
按上圖設定,注意的是,“不限”那裡先随便選擇,儲存後再修改成“不限”,然後“更新”,生成檔案。
這裡有兩個問題:
1.生成欄目和文章連結如/npx ,/a/npx/2014/0829/447.html等,沒有域名,這個問題從背景=》核心設定=》再如下圖開啟支援多站點
2.生成好多個sitemap.xml,這個問題如下圖更改
至此織夢中html和xml格式的網站地圖就生成了。