dedecms如何制作sitemap-仿wordpress google sitemap

| | Comments (1)



自己一向喜欢wp的sitemap插件制作出来的google sitemap,界面真的很好。今天抽空像挤奶一样挤了1个小时,查了点资料,通过测试确认可用后发布出来供大家下载,源文件不打算打包提供下载,请按照步骤做,一共四步。

首先关于dedecms仿wordpress sitemap的效果,请预览http://www.tbhzp.com/sitemap.xml,文章有点长,看不完拉倒吧你。

1、添加导航。打开/dede/inc/inc_menu.php文件,找到

<m:item name='更新主页HTML' link='makehtml_homepage.php' rank='sys_MakeHtml' target='main' />

     复制一条,并修改为

<m:item name='更新Sitemap' link='makehtml_sitemap.php' rank='sys_MakeHtml' target='main' />

2、制作dede/makehtml_sitemap.php文件,直接拷贝一个dede/makehtml_homepage.php文件,找到

$pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$templet);
 $pv->SaveToHtml($homeFile);

这段代码,将其删除,底部请修改调用生成文件模板为makehtml_sitemap.htm,然后另存为makehtml_sitemap.php,上传至dede/即可。


3、制作后台更新模板文件dede/templets/makehtml_sitemap.htm,直接拷贝一个dede/templets/makehtml_sitemap.htm文件,找到

<input name="templet" type="text" id="templet" style="width:300″ value="<?php echo $row['templet']?>">



<td height="20″ valign="top" bgcolor="#FFFFFF"><input name="position" type="text" id="position" value="<?php echo $row['position']?>" size="30″>

分别修改为:

<input name="templet" type="text" id="templet" style="width:300″ value="default/sitemap.xml">

<td height="20″ valign="top" bgcolor="#FFFFFF"><input name="position" type="text" id="position" value="../sitemap.xml" size="30″>

然后另存为makehtml_sitemap.htm,上传至dede/templets/;

4、制作sitemap模板文件templets/sitemap.xml,将

<?xml version="1.0" encoding="gb2312"?><?xml-stylesheet type="text/xsl" href="/templets/css/sitemap.xsl"?><!-- generator="dedecms/3.2" -->
        <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
        <url>
        <loc>http://www.babyshoot.cn</loc>         
        <lastmod>{dede:tagname runphp='yes'}@me = date("Y-m-d H:i:s", time());{/dede:tagname}</lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
        </url>
        
        {dede:arclistsg row=2000 titlelen=320  channelid='-98' typeid=''}
        <url>
        <loc>[field:arcurl /]</loc>
        <lastmod>[field:pubdate function=MyDate('Y-m-d-H:i:s',@me)/]</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.2</priority>

        </url>
        {/dede:arclistsg}
        
        
        <!-- spoint.babyshoot.cn -->
        <url>
        <loc>http://spoint.babyshoot.cn</loc>         
        <lastmod>{dede:tagname runphp='yes'}@me = date("Y-m-d H:i:s", time());{/dede:tagname}</lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
        </url>
        
        {dede:arclist row=2000 titlelen=320  typeid=''}
        <url>
        <loc>[field:arcurl /]</loc>
        <lastmod>[field:pubdate function=MyDate('Y-m-d-H:i:s',@me)/]</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.2</priority>

        </url>
        {/dede:arclist}
        
        </urlset>

用记事本将这段代码存为sitemap.xml,上传至templets/,需要说明下,这个sitemap.xml一共提供了两个范例,dede:arclist和dede:arclistsg(后者需要写明独立模型频道id),另外必须把sitemap.xsl文件下载到本地调用,请查看源码下载文件即可。希望大家喜欢哦,效果好不好,请预览http://www.tbhzp.com/sitemap.xml

单点日志:http://spoint.babyshoot.cn/

1 Comments

提交sitemap时间格式google提示错误,时间的获取方式[field:pubdate function=MyDate('Y-m-d',@me)/]可以修改为[field:pubdate function=MyDate('Y-m-d',@me)/]T[field:pubdate function=MyDate('H:i:s+08:00',@me)/],

提交google时间格式必须完全按照约定格式:

2005-06-03T04:20:32-08:00是用来指定该链接的最后更新时间,这个很重要。Google的机器人会在索引此链接前先和上次索引记录的最后更新时间进行比较,如果时间一样就会跳过不再索引。所以如果你的链接内容基于上次Google索引时的内容有所改变,应该更新该时间,让Google下次索引时会重新对该链接内容进行分析和提取关键字。这里必须用ISO 8601中指定的时间格式进行描述,格式化的时间格式如下:
年:YYYY(2005)
年和月:YYYY-MM(2005-06)
年月日:YYYY-MM-DD(2005-06-04)
年月日小时分钟:YYYY-MM-DDThh:mmTZD(2005-06-04T10:37+08:00)
年月日小时分钟秒:YYYY-MM-DDThh:mmTZD(2005-06-04T10:37:30+08:00)
这里需注意的是TZD,TZD指定就是本地时间区域标记,像中国就是+08:00了

Leave a comment

Archives

Ads by google

Pages

Powered by Movable Type 4.24-en

About this Entry

This page contains a single entry by 单点日志 published on September 4, 2011 2:51 PM.

天网:夺命之恋 传销若的祸 was the previous entry in this blog.

站长工具常用必备工具12款 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.