Hmm both sitemaps look ok. They also comply with sitemap.org so it must be something else.
What happens if you swap files? Does the one with urlset still display incorrectly?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to display my sitemaps. Browsers display my sitemap index as xml but treat post sitemaps as plain text.
I tried to override content type with below configuration but it didn't help.
location ~ \.xml$ {
proxy_hide_header Content-Type;
add_header Content-Type "application/xml";
}
How do I force nginx to set content type as "application/xml" ?
sitemap index = https://gamercortex.com/sitemap.xml sitemap1 = https://www.gamercortex.com/sitemaps/sitemap-1.xml
How can I fix this ?
Hmm both sitemaps look ok. They also comply with sitemap.org so it must be something else.
What happens if you swap files? Does the one with urlset still display incorrectly?
@AURAWINDSURFING - @aurawindsurfing Well sitemap index still works.. But other files not..
Must be something silly and small but I can not see it. What happens when you swap file contents?
@aurawindsurfing I think I might be get into close.. instead of language by language, I generated sitemaps by url. (page or post) Actually that preferred by google.
<loc>http://app.test/en/terms-of-use</loc>
<xhtml:link rel="alternate" hreflang="en" href="http://app.test/en/terms-of-use" />
<xhtml:link rel="alternate" hreflang="fr" href="http://app.test/fr/terms-of-use" />
<xhtml:link rel="alternate" hreflang="tr" href="http://app.test/tr/terms-of-use" />
<lastmod>2019-02-11T00:00:00+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>1</priority>
</url>
Browsers crashing and displaying as plain txt when they displaying the above urlset.
<loc>http://app.test/en/terms-of-use</loc>
<lastmod>2019-02-11T00:00:00+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>1</priority>
</url>
But when I remove alternate tags, it works fine. they displaying as xml file.
I also find several peoples that having same problem and first one have solution.. But I'm not sure whether is safe or not
https://productforums.google.com/forum/#!topic/webmasters/xqyE6lKWGJw;context-place=topicsearchin/webmasters/authorid$3AAPn2wQcbeJ21Qr7kXCe7rxcTISTs5emnJZxb62hsTMjT2npRLo_SS8-BqJjRlrfaj4koq5meFme1%7Csort:date%7Cspell:false
https://stackoverflow.com/questions/20330837/multilingual-sitemap-xml-file
I use this spatie package for sitemaps and they work just fine spatie/laravel-sitemap maybe try to generate with it?
I also have multilingual sites.
@aurawindsurfing Are you having any custom configuration for multilingual sitemap ? I looked github readme file but couldn't find. I generated files with preferred method and it gets me into this..
I also checked out vendor files, xhtml namespaces are hardcoded.. so I'll will fork package I guess
Nothing fancy just that:
$sitemap = Sitemap::create()
->add(Url::create(url('/pl'))
->setPriority(1.0)
->setLastModificationDate(Carbon::yesterday())
->setChangeFrequency(Url::CHANGE_FREQUENCY_WEEKLY)
->addAlternate(url('/en'), 'en'))
->add(Url::create(url('/pl/kontakt'))
->setPriority(0.9)
->setLastModificationDate(Carbon::yesterday())
->setChangeFrequency(Url::CHANGE_FREQUENCY_WEEKLY)
->addAlternate(url('/en/contact-us'), 'en'));
for each site section and it works just fine
@aurawindsurfing that's exactly what I do.. But still..
https://www.gamercortex.com/sitemaps/sitemap-1.xml
If you remove the namespace xmlns:xhtml so your sitemap ends up like the browser renders it as an xml.
See also these two tickets: https://stackoverflow.com/questions/51923627/xml-sitemap-rendering-as-plain-text and https://stackoverflow.com/questions/24864254/google-multilingual-sitemap-issue
It refers to a page that says that the namespace xhtml:link is not supported you should use another namespace.
For example, the same sitemap but without namespaces works perfectly fine.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.gamercortex.com/en</loc>
<link rel="alternate" hreflang="en" href="https://www.gamercortex.com/en" />
<link rel="alternate" hreflang="fr" href="https://www.gamercortex.com/fr" />
<link rel="alternate" hreflang="tr" href="https://www.gamercortex.com/tr" />
<lastmod>2019-02-10T00:00:00+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>1</priority>
</url>
<url>
<loc>https://www.gamercortex.com/en/cpus</loc>
<link rel="alternate" hreflang="en" href="https://www.gamercortex.com/en/cpus" />
<link rel="alternate" hreflang="fr" href="https://www.gamercortex.com/fr/cpus" />
<link rel="alternate" hreflang="tr" href="https://www.gamercortex.com/tr/cpus" />
<lastmod>2019-02-10T00:00:00+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>1</priority>
</url>
<url>
<loc>https://www.gamercortex.com/en/games</loc>
<link rel="alternate" hreflang="en" href="https://www.gamercortex.com/en/games" />
<link rel="alternate" hreflang="fr" href="https://www.gamercortex.com/fr/games" />
<link rel="alternate" hreflang="tr" href="https://www.gamercortex.com/tr/games" />
<lastmod>2019-02-10T00:00:00+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>1</priority>
</url>
<url>
<loc>https://www.gamercortex.com/en/games/gamefinder</loc>
<link rel="alternate" hreflang="en" href="https://www.gamercortex.com/en/games/gamefinder" />
<link rel="alternate" hreflang="fr" href="https://www.gamercortex.com/fr/games/gamefinder" />
<link rel="alternate" hreflang="tr" href="https://www.gamercortex.com/tr/games/gamefinder" />
<lastmod>2019-02-10T00:00:00+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>1</priority>
</url>
<url>
<loc>https://www.gamercortex.com/en/gpus</loc>
<link rel="alternate" hreflang="en" href="https://www.gamercortex.com/en/gpus" />
<link rel="alternate" hreflang="fr" href="https://www.gamercortex.com/fr/gpus" />
<link rel="alternate" hreflang="tr" href="https://www.gamercortex.com/tr/gpus" />
<lastmod>2019-02-10T00:00:00+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>1</priority>
</url>
</urlset>
@click I see, but if we skip the namespace, would it be problem for crawlers ? Does it effect seo somehow ?
@hsntngr I don't know. You can just submit your sitemap to google and see what they think. Otherwise follow the details in my previous links. They explain that you need to pass another namespace.
But on the other side, how bad is it that your browser does not load the XML correctly. The xml is made for crawlers so I wouldn't worry about not loading the xml well in the browser as long as google can read it.
Please or to participate in this conversation.