分享

dedecms制作网站地图 wordpress经典google sitemap

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

首先关于dedecms仿wordpress sitemap的效果,请预览http://www./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./2001/XMLSchema-instance" xsi:schemaLocation="http://www./schemas/sitemap/0.9 http://www./schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www./schemas/sitemap/0.9">
        <url>
        <loc>http://www.</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. -->
        <url>
        <loc>http://spoint.</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./sitemap.xml

提交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了


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

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多