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,通過修改可以定義樣式
可以參考我的這個頁面http://www.bdf029.cn/sitemap.html,樣式也在頁面head中,不過用織夢的{dede:global name='maplist'/}生成的只有兩級目錄,后邊我會把生成無限級的方法貼出來讓大家參考。
二.織夢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格式的網站地圖就生成了。
原文鏈接:http://www.arangda.com/11.html