Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gatsby 5 - sitemap.xml #178

Open
andreav opened this issue Jun 16, 2023 · 1 comment
Open

Gatsby 5 - sitemap.xml #178

andreav opened this issue Jun 16, 2023 · 1 comment

Comments

@andreav
Copy link

andreav commented Jun 16, 2023

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
Copy link
Author

andreav commented Jun 30, 2023

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

  • using standard gatsby-plugin-sitemap configuration (nothing at all, just listing the plugin inside gatsby-config.js)
  • generating on every page hreflang links

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/">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant