织梦DedeCms纯代码创建sitemap.xml

2016年3月25日 建站技术 浏览 3,107 抢沙发 A+

织梦本身有sitemap.xml创建功能,不过不太用,而且太乱太杂,不好用,下面介绍的纯代码创建符合百度收录标准的xml网站地图sitemap!

织梦DedeCms纯代码创建sitemap.xml

步骤如下:

1、创建sitemap.xml文件,并放入模板文件夹中,sitemap.xml里面的代码为:

<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://yourdomain</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>
<url>
<loc>http://yourdomain/sitemap.xml</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='30' type='top'}
<url>
  <loc>http://yourdomain{dede:field name='typeurl'/}</loc>
  <changefreq>daily</changefreq>
  <priority>0.6</priority>
</url>
{/dede:channel}
{dede:arclist row=1000 orderby=id}
<url>
<loc>http://yourdomain[field:arcurl/]</loc>
<lastmod>[field:pubdate function=strftime('%Y-%m-%d',@me)/]</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
{/dede:arclist}
</urlset>

创建好文件之后,把sitemap.xml放入模板文件夹中。

温馨提示:记得把yourdomain改为自己的网址哦!

2、接着更新网站首页,设置如下图:

织梦DedeCms纯代码创建sitemap.xml

方法很简单,方便修改,广大织梦CMS爱好者记得多分享哦!

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: