Invalid lastmod date in sitemap.xml

In my sitemap.xml are many (not all) webpages with invalid lastmod-dates:

<url>
  <loc>YYY</loc>
  <lastmod>0001-01-01T00:00:00+00:00</lastmod>
</url>

What is the reason of this and how can I solve it?

This is usually a sign that the date in your content’s front-matter is not in a proper format.

E.g. If you use date: 2015-09-09T15:06:24+01:00 or date: 2015-09-09, your templates will render the date correctly. However if you use date: 2015-09-, they will fail and result in the date-timestamp you have above.

1 Like

Hi there,

I have the following in my sitemap.xml template that seems to follow the format you specify:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  {{ range .Data.Pages }}
  <url>
    <loc>{{ .Site.BaseURL }}</loc>
    <lastmod>{{ safeHTML ( .Date.Format "2015-09-09T15:06:24+01:00" ) }}</lastmod>{{ with .Sitemap.ChangeFreq }}
    <changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
    <priority>{{ .Sitemap.Priority }}</priority>{{ end }}
  </url>
  {{ end }}
</urlset>

However when rendered it’s incorrect:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

  <url>
    <loc>http://www.mywebsite.com/</loc>
    <lastmod>10100-09-09T00:01:10+01:00</lastmod>
    <priority>0</priority>
  </url>

</urlset>

Any ideas why this might be the case?

Check your date(s) in the page front matter.

Hi

how about trying the code below?

<lastmod>{{ safeHTML ( .Now.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>

I have this problem in the entry of categories and tags.

<url><loc>http://www.hasecke.com/categories/</loc><lastmod>0001-01-01T00:00:00+00:00</lastmod><priority>0</priority></url><url>
<url><loc>http://www.hasecke.com/tags/</loc><lastmod>0001-01-01T00:00:00+00:00</lastmod><priority>0</priority></url>

How to change the date of these automatically rendered pages?

I disabled taxonomies at all with:

disableKinds = ["taxonomy","taxonomyTerm"]

and the entry went away.