withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.43k stars 2.46k forks source link

Astro/sitemap i18n error #5487

Closed manuelernestog closed 1 year ago

manuelernestog commented 1 year ago

What version of astro are you using?

1.6.11

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

When you generate a sitemap using i18n config, the format of the sitemap-0.xml file is incorrect and tools like Google Search Console can't find any pages in it.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-de1e3v

Participation

delucis commented 1 year ago

Hi @manuelernestog! Could you provide some more information about what exactly is wrong with the format?

manuelernestog commented 1 year ago

Hi @delucis, sure!

When you generate a Sitemap with Astro Sitemap Integration, it creates two files, the sitemap-index and the sitemap-0.xml

If you take a look at some sitemap-0.xml without the i18n config, it's look like this in the web browser

Screenshot from 2022-11-29 00-56-36

Now if you take a look at one generated with the i18n config, it's look like this

image

And it should look like this

image

As you can see, the web browser is not recognizing this as a xml valid file and Google Search Console is also unable to recognize URLs in the file

image

The minimal example have a website with just two index files (one for English and one for French). When you build the page and preview it you will find the same problem in the generated XML file.

matthewp commented 1 year ago

Is this a bug with Astro or with astro-i18next? It's unclear to me. Can you create an example that takes astro-i18next out of the equation?

delucis commented 1 year ago

Our docs site doesn’t use i18next but does use the i18n sitemap config and the sitemap renders without browser styles like OP’s example: https://docs.astro.build/sitemap-0.xml

(Worth noting though that’s a browser rendering quirk: if you “View source” or download the XML file, you’ll see the XML markup is still there.)

But we don’t have the same search console error:

image
matthewp commented 1 year ago

@manuelernestog can you let us know what is wrong with the actual XML (and not how it's rendered by the browser)?

manuelernestog commented 1 year ago

Sure @matthewp. First as you suggested before let me create an example without astro-i18next Although it should not be interfering, it could be the reason for the problem.

Our docs site doesn’t use i18next but does use the i18n sitemap config and the sitemap renders without browser styles like OP’s example: https://docs.astro.build/sitemap-0.xml

(Worth noting though that’s a browser rendering quirk: if you “View source” or download the XML file, you’ll see the XML markup is still there.)

But we don’t have the same search console error: image

Thanks for the information @delucis, seeing this then maybe it could be some incompatibility problem with the plugin

I'm going to create another Minimal Reproducible Example to check if it's a compatibility issue with the plugin i18n or is it something else. I'll get back to you as soon as I have it.

matthewp commented 1 year ago

Closing as stale, please reopen if you still see. an issue. Thanks!