织梦系统默认是自带有网站地图模板的,但是生成之后的网站地图是在data文件内,而一般的data文件夹都是被屏蔽的,这样不利于网站的优化,为了文章的收录,那么怎么修改呢?
默认的情况下,网址地图是放在如下路径下的。
站点地图的模板:templets/plus/sitemap.htm
rss地图的模板:templets/plus/rssmap.htm
进入网站,将dede文件下makehtml_map.php中的$cfg_cmspath."/data/sitemap.html";和$cfg_cmspath."/data/rssmap.html";里的/data去掉。将$tmpfile语句中plus去掉,这样调用后台设置的默认模板路径。
然后,再将根目录下include文件中的arc.rssview.class.php里$murl = $GLOBALS['cfg_cmspath']."/data/rss/".$this->TypeID.".xml";的/data去掉。同时,还将sitemap.class.php里的$typelink = $GLOBALS['cfg_cmsurl']."/data/rss/".$row->id.".xml";和$typelink = $GLOBALS['cfg_cmsurl']."/data/rss/".$row->id.".xml";的/data也去掉。
然后,进入织梦后,点击生成,地图和RRS生成即可。
这样生成的都为html文件,那xml呢?
新建一个空白txt文档,将文档名字改为sitemap.xml,将下面代码放到文档中
<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.9">
<url>
<loc>http://www.xiuzhanwang.com/</loc>
<lastmod>{dede:arclist row=1 titlelen=24 orderby=pubdate}[field:pubdate function=strftime('%Y-%m-%d',@me)/]{/dede:arclist}</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
{dede:channel row='23' type='top'}
<url>
<loc>http://www.xiuzhanwang.com{dede:field name='typeurl'/}</loc>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
{/dede:channel}
{dede:arclist row=2000 orderby=pubdate}
<url>
<loc>http://www.xiuzhanwang.com[field:arcurl/]</loc>
<lastmod>[field:pubdate function=strftime('%Y-%m-%d',@me)/]</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
{/dede:arclist}
</urlset>
然后将文档拷贝在模板文件中
接着更新网站首页,设置如下图:
更新主页,sitemap.xml便做好了。