microapps / gatsby-plugin-react-i18next

Easily translate your Gatsby website into multiple languages
MIT License
121 stars 72 forks source link

Gatsby 5 - sitemap.xml #178

Open andreav opened 1 year ago

andreav commented 1 year ago

Hello, sorry but I'm a bit confused about how to generate the sitemap.xml

I tried the code in the README.md but it is not working. Then I found different threads about this topic, I tried them with no luck. Which is the recommended method as of today?

Thank you.

My package.json is:

"gatsby": "^5.11.0",
"gatsby-plugin-react-i18next": "^3.0.1",
"gatsby-plugin-sitemap": "^6.11.0",
andreav commented 1 year ago

In the end I adopted this solution, I hope it will be useful to the reader:

Every page has links like in the following example (this example is referring to the / root page). Note: I'm using generateDefaultLanguagePage: false, my default language is en so for this language I'm doing a little differently.

<link rel="alternate" hreflang="x-default" href="https://www.MYURL/">
<link rel="alternate" hreflang="af" href="https://www.MYURL/af/">
...
<link rel="alternate" hreflang="en" href="https://MYURL/">
...
<link rel="alternate" hreflang="vi" href="https://MYURL/vi/">