How to properly format last modified (lastmod) time for xml sitemaps

后端 未结 6 471
礼貌的吻别
礼貌的吻别 2021-02-05 05:37

I am creating an app that will automatically update sitemap.xml each time new content is added to, or updated on the site.

According to Google\'s best pract

6条回答
  •  抹茶落季
    2021-02-05 06:24

    The lastmod tag is optional in sitmaps and in most of the cases it's ignored by search engines, because webmasters are doing a horrible job keeping it accurate. In any case, you may use it, and the format depends on your capabilities and requirements; you don't actually have to provide a timezone offset if you can't or don't want to, you can choose to go with a simple YYYY-MM-DD as well.

    From the Lastmod definition section of sitemaps.org:

    The date of last modification of the file. This date should be in W3C Datetime format. This format allows you to omit the time portion, if desired, and use YYYY-MM-DD.

    If you want to go down to that granularity and provide the timezone offset as well, you're correct, it's UTC +/-. From W3C Datetime:

    Times are expressed in local time, together with a time zone offset in hours and minutes. A time zone offset of "+hh:mm" indicates that the date/time uses a local time zone which is "hh" hours and "mm" minutes ahead of UTC. A time zone offset of "-hh:mm" indicates that the date/time uses a local time zone which is "hh" hours and "mm" minutes behind UTC.

    And example, still from W3C:

    1994-11-05T08:15:30-05:00 corresponds to November 5, 1994, 8:15:30 am, US Eastern Standard Time.

提交回复
热议问题