新建一个sitemap.php, 里面内容如下:
<?php require_once( 'couch/cms.php' ); ?><cms:content_type 'text/xml' /><cms:concat '<' '?xml version="1.0" encoding="' k_site_charset '"?' '>' /><cms:concat '<' '?xml-stylesheet type="text/xsl" href="' k_site_link 'main-sitemap.xsl"?' '>' />
<cms:template title='Sitemap' parent='_modules_' >
<cms:editable type='group' name='pages' label='Pages' >
<cms:templates show_hidden='1' order='asc'>
<cms:if k_template_is_executable='1'>
<cms:editable type='radio' name="tpl_<cms:show k_template_id />_page" opt_values='In sitemap=1 | Not in sitemap=0' label="<cms:show k_template_title />" group='pages' opt_selected = '1' desc="<cms:show k_template_link />" />
</cms:if>
</cms:templates>
</cms:editable>
<cms:editable type='group' name='post_types' label='Post Types'>
<cms:templates show_hidden='1' order='asc'>
<cms:if k_template_is_clonable='1' && k_template_is_executable='1'>
<cms:editable type='radio' name="tpl_<cms:show k_template_id />" opt_values='In sitemap=1 | Not in sitemap=0' label="<cms:show k_template_title /> Posts" group='post_types' opt_selected = '1' />
<cms:if k_template_has_dynamic_folders = '1'>
<cms:editable type='radio' name="tpl_<cms:show k_template_id />_folder" opt_values='In sitemap=1 | Not in sitemap=0' label="<cms:show k_template_title /> - Folder Views" group='post_types' opt_selected = '0' />
</cms:if>
</cms:if>
</cms:templates>
</cms:editable>
<cms:editable type='group' name='post_excludes' label='Exclude Posts'>
<cms:editable type='text' name='excluded_posts' label='Exclude Posts' desc='You can exclude posts by entering a comma separated string. E.g.: 1,2,99,100' validator="regex=/^\d+(,\d+)*$/"/>
</cms:editable>
</cms:template>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<cms:templates show_hidden='1' order='asc' >
<cms:if k_template_is_clonable="1" && k_template_is_executable="1">
<cms:if "<cms:get "tpl_<cms:show k_template_id />_page" />">
<url>
<loc><cms:show k_template_link /></loc>
<lastmod>
<cms:pages limit='1' masterpage=k_template_name orderby='modification_date'>
<cms:date "<cms:if k_page_modification_date='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else /><cms:show k_page_modification_date /></cms:if>" format='Y-m-d' />
</cms:pages>
</lastmod>
<changefreq>daily</changefreq>
</url>
</cms:if>
<cms:if "<cms:get "tpl_<cms:show k_template_id />" />">
<cms:pages masterpage=k_template_name>
<cms:php>
global $CTX;
$array = array(<cms:show excluded_posts />);
$post_id = $CTX->get( 'k_page_id' );
$CTX->set ( 'excluded', '0' );
if (in_array($post_id, $array)) { $CTX->set ( 'excluded', '1' );}
</cms:php>
<cms:if excluded='0'>
<url>
<loc><cms:show k_page_link /></loc>
<lastmod>
<cms:date "<cms:if k_page_modification_date='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else /><cms:show k_page_modification_date /></cms:if>" format='Y-m-d' />
</lastmod>
<changefreq>daily</changefreq>
</url>
</cms:if>
</cms:pages>
</cms:if>
<cms:if "<cms:get "tpl_<cms:show k_template_id />_folder" />">
<cms:folders masterpage=k_template_name>
<url>
<loc><cms:show k_folder_link /></loc>
<lastmod>
<cms:pages limit='1' masterpage=k_template_name orderby='modification_date'>
<cms:date "<cms:if k_page_modification_date='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else /><cms:show k_page_modification_date /></cms:if>" format='Y-m-d' />
</cms:pages>
</lastmod>
<changefreq>daily</changefreq>
</url>
</cms:folders>
</cms:if>
<cms:else />
<cms:if k_template_is_executable='1'>
<cms:if "<cms:get "tpl_<cms:show k_template_id />_page" />">
<url>
<loc><cms:show k_template_link /></loc>
<lastmod>
<cms:query sql="SELECT p.modification_date FROM dpcn_couch_pages p WHERE p.template_id = '<cms:show k_template_id/>'">
<cms:date "<cms:if modification_date='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else /><cms:show modification_date /></cms:if>" format='Y-m-d' />
</cms:query>
</lastmod>
<changefreq>daily</changefreq>
</url>
</cms:if>
</cms:if>
</cms:if>
</cms:templates>
</urlset>
<?php COUCH::invoke(); ?>
然后运行此文件 https//www.yourdomain.com/sitemap.php
刷新后台可以设置。
给搜索引擎提交此网址即可。
但是百度还有一些国产搜索引擎不可以提交此网址,必须要sitemap.xml怎么办。
当然这个网址并非以xml结尾的,google也并不要求必须xml结尾,但您确实需要的话,
我们还有.htaccess文件可以操作伪静态
添加以下规则即可:
RewriteRule ^sitemap\.xml$ sitemap.php [L]
sitemap.php文件运行后,相当于一个模块会自动生成标准xml格式的网站地图
访问地址为,http://www.xxxx.com/sitemap.php
可以启用伪静态:http://www.xxx.com/sitemap
main-sitemap.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XML Sitemap</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://tablesorter.com/jquery.tablesorter.min.js"></script>
<script type="text/javascript"><![CDATA[
$(document).ready(function() {
$("#sitemap").tablesorter( { widgets: ['zebra'] } );
});
]]></script>
<style type="text/css">
body {
font-family: Helvetica, Arial, sans-serif;
font-size: 13px;
color: #545353;
background:#336666;
margin:0;
}
table {
border: none;
border-collapse: collapse;
}
#sitemap tr{
border-bottom:1px solid #eee;
}
#sitemap tr.odd {
background-color: #eee;
}
#sitemap tbody tr:hover {
background-color: #ccc;
}
#sitemap tbody tr:hover td, #sitemap tbody tr:hover td a {
color: #000;
}
#content {
margin: 0 auto;
width: 1000px;
background:#fff;
padding:16px;
}
#content h1{
font-weight:100;
}
.expl {
margin: 10px 3px;
line-height: 1.3em;
}
.expl a {
color: #da3114;
font-weight: bold;
}
a {
color: #000;
text-decoration: none;
}
a:visited {
color: #777;
}
a:hover {
text-decoration: underline;
}
td {
font-size:11px;
}
th {
text-align:left;
padding-right:30px;
font-size:11px;
}
thead th {
border-bottom: 1px solid #000;
cursor: pointer;
}
</style>
</head>
<body>
<div id="content">
<h1>XML Sitemap</h1>
<p class="expl">
Dynamically generated by <a href="www.couchcms.com">CouchCMS</a>, this is an XML Sitemap, meant for consumption by search engines.
</p>
<p class="expl">
You can find more information about XML sitemaps on <a href="http://sitemaps.org">sitemaps.org</a>.
</p>
<p class="expl">
This sitemap contains <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> URLs.
</p>
<table id="sitemap" cellpadding="3">
<thead>
<tr>
<th width="75%">URL</th>
<th width="10%">Change Freq.</th>
<th width="10%">Last Change</th>
</tr>
</thead>
<tbody>
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:for-each select="sitemap:urlset/sitemap:url">
<tr>
<td>
<xsl:variable name="itemURL">
<xsl:value-of select="sitemap:loc"/>
</xsl:variable>
<a href="{$itemURL}">
<xsl:value-of select="sitemap:loc"/>
</a>
</td>
<td>
<xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
</td>
<td>
<xsl:value-of select="sitemap:lastmod"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
文件也要传到sitemap.php同级目录,即根目录

最后记得网站config.php里开启缓存,这样我们的网站和静态网站一样快。