# Django Sitemap XML error in Google and cannot submit to Google

**URL:** <https://forum.djangoproject.com/t/django-sitemap-xml-error-in-google-and-cannot-submit-to-google/23615>\
**Category:** Deployment\
**Created:** [September 4, 2023, 11:08am UTC](https://forum.djangoproject.com/t/django-sitemap-xml-error-in-google-and-cannot-submit-to-google/23615 "2023-09-04T11:08:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anefta](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/anefta/32/10649_2.png) [@anefta](https://forum.djangoproject.com/u/anefta)\
**Post date:** [September 4, 2023, 11:08am UTC](https://forum.djangoproject.com/t/django-sitemap-xml-error-in-google-and-cannot-submit-to-google/23615/1 "2023-09-04T11:08:50Z")

</div>

I have successfully created an index sitemap.xml with other sitemap sections.  
BUT when I try to submit my sitemap.xml to google it is not fetched and page speed insights: [https://pagespeed.web.dev/](https://pagespeed.web.dev/) gives the error: **Error!**  
**The page provided is not HTML (served as MIME type application/xml).**

I can see fine my sitemaps on my webiste but Google and Pagespeed do not like them.

After some digging I checked the headers of sitemap.xml and they are wrong - I do not understand how they came from:

```auto
curl -IA "Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.175 Mobile Safari/537.36 Chrome-Lighthouse" 'https://WEBSITE/sitemap.xml'

```

Here is the result of previous command:

```auto
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Mon, 04 Sep 2023 10:31:03 GMT
Content-Type: application/xml
Content-Length: 1035
Connection: keep-alive
X-Robots-Tag: noindex, noodp, noarchive
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Referrer-Policy: same-origin
Cross-Origin-Opener-Policy: same-origin

```

Here is my urls.py for sitemap:

```auto
# SITEMAPS - a main sitemap with sections for sub-sitemaps.
    path("sitemap.xml", views.index, {"sitemaps": sitemaps}, name="django.contrib.sitemaps.views.index",),
    path("sitemap-<section>.xml",sitemap,
         {"sitemaps": sitemaps},
         name="django.contrib.sitemaps.views.sitemap",
    ),

```

I use nginx and the sitemaps are xml sitemaps that are generated on the fly from django.  
My robots.txt allows everything and does not block my sitemap.xml

Any ideas what is going wrong here?!

Best

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 4, 2023, 1:29pm UTC](https://forum.djangoproject.com/t/django-sitemap-xml-error-in-google-and-cannot-submit-to-google/23615/2 "2023-09-04T13:29:34Z")

</div>

The [Django sitemap framework](https://docs.djangoproject.com/en/4.2/ref/contrib/sitemaps/#module-django.contrib.sitemaps) is working exactly as intended.

The `sitemap.xml` file is exactly that - an xml file.

If you wish to generate some other kind of output, such as a web page, you need to provide a template and configure the view. See the docs for [views.sitemap](https://docs.djangoproject.com/en/4.2/ref/contrib/sitemaps/#django.contrib.sitemaps.views.sitemap).

You may need to do some research on what google is expecting in order to provide what it needs.

---

<div class="post-metadata">

**Author:** ![anefta](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/anefta/32/10649_2.png) [@anefta](https://forum.djangoproject.com/u/anefta)\
**Post date:** [September 4, 2023, 6:19pm UTC](https://forum.djangoproject.com/t/django-sitemap-xml-error-in-google-and-cannot-submit-to-google/23615/3 "2023-09-04T18:19:19Z")

</div>

> [@KenWhitesell](#):
>
> le is expecting in order to provide what it needs.

Thank you for your suggestion - it appears that Google Pagespeed has a bug because I tested and with no django sitemaps.xml and it returned the same error. Now, Google search console, accepted the submitted sitemaps despite the fact of the pagespeed error…
