代码之家  ›  专栏  ›  技术社区  ›  BitDrink

动态PHP网站的站点地图…需要“lastmod”字段吗?

  •  0
  • BitDrink  · 技术社区  · 16 年前

    在每个“url”元素中都有字段:loc、lastmod、changefreq和priority。

    http://www.xml-sitemaps.com/ 为了验证它是否正确,我注意到在生成的站点地图中没有“lastmod”字段!

    在GoogleWiki中,关于如何编写站点地图,有一篇文章写道,即使对于动态页面,设置“lastmod”字段也是一个很好的实践;所以,我的问题是。。。

    谢谢你!

    4 回复  |  直到 16 年前
        1
  •  1
  •   Pascal MARTIN    16 年前

    标准上说它是可选的: http://www.sitemaps.org/protocol.php#locdef :

    <lastmod> 可选择的

    文件此日期应为W3C格式 如果需要,请忽略时间部分

    不过,让搜索引擎/蜘蛛知道您的内容最后一次更新的时间可能还是有用的。


    这个 How do I compute lastmod date? FAQ的条目也给出了一个有趣的原因,这解释了如果可以的话,为什么应该包括lastmod日期 :

    时间戳可以帮助爬虫避免 这将减少带宽和CPU 对web服务器的要求。

        2
  •  2
  •   bstpierre Edgar Aviles    15 年前
    $lastmod = date('Y-m-dTH:i:s+00:00');
    

    欲了解更多信息, http://www.w3.org/TR/NOTE-datetime

        3
  •  2
  •   Krishnamoorthy Acharya    7 年前

    您可以使用php日期函数创建最后一个mod

    如何创建最后一个模式值 enter image description here

    <sitemap>
        <loc><?php echo url('/') ?>/sitemap/uk/lse/list</loc>
        <lastmod><?php echo date('c', time()); ?></lastmod>
    </sitemap>
    
        4
  •  0
  •   cherouvim    16 年前

    It's not mandatory 但是,当你的网站上发生内容更新时,为了让谷歌(和其他引擎)知道,拥有它是件好事。