# Sitemap: \`lastmod\` errato per le sitemap

**URL:** <https://meta.discourse.org/t/sitemap-lastmod-for-sitemaps-wrong/299702>\
**Category:** Bug\
**Tags:** sitemap\
**Created:** [17 Marzo 2024, 2:21pm UTC](https://meta.discourse.org/t/sitemap-lastmod-for-sitemaps-wrong/299702 "2024-03-17T14:21:55Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![rrit](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@rrit](https://meta.discourse.org/u/rrit)\
**Post date:** [17 Marzo 2024, 2:21pm UTC](https://meta.discourse.org/t/sitemap-lastmod-for-sitemaps-wrong/299702/1 "2024-03-17T14:21:55Z")

</div>

Nella sitemap principale, la data `lastmod` per le sitemap sottostanti è errata:

Ad esempio, vedi [https://meta.discourse.org/sitemap.xml](https://meta.discourse.org/sitemap.xml)  
Le date per `sitemap_2.xml` fino a `sitemap_5.xml` sono tutte uguali ‘2024-03-14T14:02:32Z’ - che è esattamente ‘3 giorni fa’.

```xml
<sitemapindex>
    <sitemap>
        <loc>https://meta.discourse.org/sitemap_recent.xml</loc>
        <lastmod>2024-03-17T14:02:29Z</lastmod>
    </sitemap>
    <sitemap>
        <loc>https://meta.discourse.org/sitemap_1.xml</loc>
        <lastmod>2024-03-17T14:02:29Z</lastmod>
    </sitemap>
    <sitemap>
        <loc>https://meta.discourse.org/sitemap_2.xml</loc>
        <lastmod>2024-03-14T14:02:32Z</lastmod>
    </sitemap>
    <sitemap>
        <loc>https://meta.discourse.org/sitemap_3.xml</loc>
        <lastmod>2024-03-14T14:02:32Z</lastmod>
    </sitemap>
    <sitemap>
        <loc>https://meta.discourse.org/sitemap_4.xml</loc>
        <lastmod>2024-03-14T14:02:32Z</lastmod>
    </sitemap>
    <sitemap>
        <loc>https://meta.discourse.org/sitemap_5.xml</loc>
        <lastmod>2024-03-14T14:02:32Z</lastmod>
    </sitemap>
</sitemapindex>

```

### Problema tecnico:

In qualche modo viene utilizzato `3.days.ago` per sitemap\_[2-5].xml poiché `sitemap.last_posted_topic` potrebbe non restituire un valore valido.

> <https://github.com/discourse/discourse/blob/d0d659e7330e1221f57cf6202a8de5c1604556f6/app/models/sitemap.rb#L27-L31>

> <https://github.com/discourse/discourse/blob/d0d659e7330e1221f57cf6202a8de5c1604556f6/app/models/sitemap.rb#L44-L46>

### Altro punto: in `last_posted_topic` usa anche `bumped_at`

Confronta con `lastmod` nelle sitemap dei topic sitemap\_[1-5].xml stesse:

> <https://github.com/discourse/discourse/blob/d0d659e7330e1221f57cf6202a8de5c1604556f6/app/views/sitemap/page.xml.erb#L10-L13>

Pseudo-codice non testato:

```rb
    def last_posted_topic
      [sitemap_topics.maximum(:bumped_at), sitemap_topics.maximum(:updated_at)].max
    end

```

---

_[View the full topic](https://meta.discourse.org/t/sitemap-lastmod-for-sitemaps-wrong/299702)._
