使用DedeCMS自带的系统生成(最简单)
这是最直接的方法,适合大多数新手和标准网站结构。

-
登录后台:使用管理员账号登录你的DedeCMS后台。
-
进入“频道管理”:在左侧菜单栏中,找到并点击 “频道管理” -> “网站地图”。
-
设置参数并生成:
- 主页名称:通常填写“网站地图”或“Sitemap”。
- 主页链接:填写你的网站首页地址,
https://www.yourdomain.com/sitemap.html。 - 栏目设置:这里是最重要的部分。
- 选择栏目:默认是“全选”,你可以取消勾选不想包含在地图中的栏目(留言板”、“会员中心”等)。
- 包含子栏目:勾选此项,会自动包含所有已选择栏目的子栏目。
- 包含外部链接:如果某个栏目设置了外部链接,勾选此项会包含它。
- 其他选项:
- 文件命名:默认是
sitemap.html,你可以自定义。 - 文件保存目录:默认是根目录 。
- 显示模式:通常选择“列表模式”即可。
- 文件命名:默认是
- 生成HTML:点击 “生成HTML” 按钮,系统会自动为你生成一个静态的
sitemap.html文件。
-
检查结果:生成成功后,访问你设置的网址(如
https://www.yourdomain.com/sitemap.html),就能看到网站地图了。
(图片来源网络,侵删)
优点:操作简单,无需修改代码。 缺点:模板样式单一,不够美观,自定义程度低。
自定义网站地图模板(最灵活)
如果你希望网站地图有特定的样式,或者想生成XML格式的Sitemap以提交给搜索引擎(如Google、百度),就需要使用自定义模板。
步骤1:创建模板文件
在DedeCMS的模板目录(通常是 /templets/ 或 /templets/default/)下,创建一个新的模板文件,sitemap_custom.htm。
步骤2:编写模板代码
根据你的需求,可以选择编写 HTML格式 或 XML格式 的模板。

示例1:HTML格式的自定义网站地图模板 (sitemap_custom.htm)
这个模板会生成一个美观、分类清晰的HTML网站地图。
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">{dede:global.cfg_webname/} - 网站地图</title>
<meta name="keywords" content="网站地图,sitemap,{dede:global.cfg_keywords/}" />
<meta name="description" content="{dede:global.cfg_webname/}网站地图,包含网站所有栏目和最新文章,方便您快速找到所需内容。" />
<link rel="stylesheet" href="{dede:global.cfg_cmsurl/}/static/css/style.css" />
<style>
body { font-family: 'Microsoft YaHei', sans-serif; line-height: 1.6; color: #333; background: #f4f4f4; }
.container { max-width: 1200px; margin: 20px auto; padding: 20px; background: #fff; border-radius: 8px; box-shadow: 0 0 10px rgba(0,0,0,0.1); }
h1 { text-align: center; color: #2c3e50; border-bottom: 2px solid #3498db; padding-bottom: 10px; }
.sitemap-section { margin-bottom: 30px; }
.sitemap-section h2 { color: #34495e; border-left: 4px solid #3498db; padding-left: 10px; }
.sitemap-list { list-style: none; padding: 0; }
.sitemap-list li { margin-bottom: 8px; }
.sitemap-list a { color: #2980b9; text-decoration: none; transition: color 0.3s; }
.sitemap-list a:hover { color: #e74c3c; text-decoration: underline; }
.footer { text-align: center; margin-top: 30px; color: #7f8c8d; font-size: 12px; }
</style>
</head>
<body>
<div class="container">
<h1>{dede:global.cfg_webname/} - 网站地图</h1>
<p>本站地图收录了所有栏目及最新发布的文章,为您导航。</p>
<!-- 栏目列表部分 -->
<div class="sitemap-section">
<h2>网站栏目</h2>
<ul class="sitemap-list">
{dede:channel type='top' row='50'}
<li><a href="[field:typelink/]">[field:typename/]</a></li>
{/dede:channel}
</ul>
</div>
<!-- 文章列表部分(可选,展示最新文章) -->
<div class="sitemap-section">
<h2>最新文章</h2>
<ul class="sitemap-list">
{dede:arclist row='20' titlelen='50'}
<li><a href="[field:arcurl/]">[field:title/]</a></li>
{/dede:arclist}
</ul>
</div>
<!-- 其他自定义部分,比如单页文档 -->
{dede:sql sql="SELECT * FROM dede_arctype WHERE ispart<>2 ORDER BY id"}
<div class="sitemap-section">
<h2>[field:typename/]</h2>
<ul class="sitemap-list">
{dede:arclist typeid='[field:id]' row='10'}
<li><a href="[field:arcurl/]">[field:title/]</a></li>
{/dede:arclist}
</ul>
</div>
{/dede:sql}
<div class="footer">
<p>Copyright © {dede:global.cfg_webname/} - <a href="{dede:global.cfg_cmsurl/}/sitemap.html">XML Sitemap</a></p>
</div>
</div>
</body>
</html>
示例2:XML格式的Sitemap模板 (sitemap.xml)
这种模板主要用于提交给搜索引擎,告诉它们网站有哪些页面可以抓取。
重要提示:XML模板文件通常放在网站根目录,并且文件名直接为 sitemap.xml,在DedeCMS后台生成时,可以直接指定文件名为 sitemap.xml。
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<!-- 首页 -->
<url>
<loc>https://www.yourdomain.com/</loc>
<lastmod>{dede:tagname runphp='yes'}@me = date('Y-m-d');{/dede:tagname}</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<!-- 一级栏目 -->
{dede:channel type='top' row='50'}
<url>
<loc>[field:typelink/]</loc>
<lastmod>{dede:tagname runphp='yes'}@me = date('Y-m-d');{/dede:tagname}</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
{/dede:channel}
<!-- 文章页 -->
{dede:arclist row='1000' orderby='pubdate'}
<url>
<loc>[field:arcurl/]</loc>
<lastmod>[field:pubdate function="MyDate('Y-m-d', @me)"/]</lastmod>
<changefreq>monthly</changefreq>
<priority>0.6</priority>
</url>
{/dede:arclist}
<!-- 自定义单页文档 -->
{dede:sql sql="SELECT * FROM dede_archives WHERE arctypeid=10 ORDER BY pubdate DESC LIMIT 100"}
<url>
<loc>https://www.yourdomain.com/view.php?aid=[field:id/]</loc>
<lastmod>[field:pubdate function="MyDate('Y-m-d', @me)"/]</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
{/dede 