Closed stevenle closed 1 month ago
I think there are two improvements to make (although I feel like depending on who I have review my sitemaps, I occasionally get different feedback):
/de/foo/
should list /en/foo/
as an alternate.x-default
item that points to that URL.I like to look at this sitemap as an example: https://mapsplatform.google.com/sitemap.xml (although it doesn't have the XML schema linked so you need to view source - that's implemented in your output correctly) :)
Oh, one other thing worth flagging (not sure if it's already accounted for though), the 404 route shouldn't be included in the sitemap (our non-Root.js projects had this as an issue for a while).
Here's the new sample output:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>https://rootjs.dev/</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://rootjs.dev/de/" />
<xhtml:link rel="alternate" hreflang="es" href="https://rootjs.dev/es/" />
<xhtml:link rel="alternate" hreflang="fr" href="https://rootjs.dev/fr/" />
<xhtml:link rel="alternate" hreflang="en" href="https://rootjs.dev/en/" />
</url>
<url>
<loc>https://rootjs.dev/en/</loc>
<xhtml:link rel="alternate" hreflang="x-default" href="https://rootjs.dev/" />
<xhtml:link rel="alternate" hreflang="de" href="https://rootjs.dev/de/" />
<xhtml:link rel="alternate" hreflang="es" href="https://rootjs.dev/es/" />
<xhtml:link rel="alternate" hreflang="fr" href="https://rootjs.dev/fr/" />
</url>
<url>
<loc>https://rootjs.dev/foo/</loc>
<xhtml:link rel="alternate" hreflang="de" href="https://rootjs.dev/de/foo/" />
<xhtml:link rel="alternate" hreflang="es" href="https://rootjs.dev/es/foo/" />
<xhtml:link rel="alternate" hreflang="fr" href="https://rootjs.dev/fr/foo/" />
<xhtml:link rel="alternate" hreflang="en" href="https://rootjs.dev/en/foo/" />
</url>
<url>
<loc>https://rootjs.dev/en/foo/</loc>
<xhtml:link rel="alternate" hreflang="x-default" href="https://rootjs.dev/foo/" />
<xhtml:link rel="alternate" hreflang="de" href="https://rootjs.dev/de/foo/" />
<xhtml:link rel="alternate" hreflang="es" href="https://rootjs.dev/es/foo/" />
<xhtml:link rel="alternate" hreflang="fr" href="https://rootjs.dev/fr/foo/" />
</url>
<url>
<loc>https://rootjs.dev/fr/</loc>
<xhtml:link rel="alternate" hreflang="x-default" href="https://rootjs.dev/" />
<xhtml:link rel="alternate" hreflang="de" href="https://rootjs.dev/de/" />
<xhtml:link rel="alternate" hreflang="es" href="https://rootjs.dev/es/" />
<xhtml:link rel="alternate" hreflang="en" href="https://rootjs.dev/en/" />
</url>
<url>
<loc>https://rootjs.dev/es/</loc>
<xhtml:link rel="alternate" hreflang="x-default" href="https://rootjs.dev/" />
<xhtml:link rel="alternate" hreflang="de" href="https://rootjs.dev/de/" />
<xhtml:link rel="alternate" hreflang="fr" href="https://rootjs.dev/fr/" />
<xhtml:link rel="alternate" hreflang="en" href="https://rootjs.dev/en/" />
</url>
<url>
<loc>https://rootjs.dev/es/foo/</loc>
<xhtml:link rel="alternate" hreflang="x-default" href="https://rootjs.dev/foo/" />
<xhtml:link rel="alternate" hreflang="de" href="https://rootjs.dev/de/foo/" />
<xhtml:link rel="alternate" hreflang="fr" href="https://rootjs.dev/fr/foo/" />
<xhtml:link rel="alternate" hreflang="en" href="https://rootjs.dev/en/foo/" />
</url>
<url>
<loc>https://rootjs.dev/de/foo/</loc>
<xhtml:link rel="alternate" hreflang="x-default" href="https://rootjs.dev/foo/" />
<xhtml:link rel="alternate" hreflang="es" href="https://rootjs.dev/es/foo/" />
<xhtml:link rel="alternate" hreflang="fr" href="https://rootjs.dev/fr/foo/" />
<xhtml:link rel="alternate" hreflang="en" href="https://rootjs.dev/en/foo/" />
</url>
<url>
<loc>https://rootjs.dev/de/</loc>
<xhtml:link rel="alternate" hreflang="x-default" href="https://rootjs.dev/" />
<xhtml:link rel="alternate" hreflang="es" href="https://rootjs.dev/es/" />
<xhtml:link rel="alternate" hreflang="fr" href="https://rootjs.dev/fr/" />
<xhtml:link rel="alternate" hreflang="en" href="https://rootjs.dev/en/" />
</url>
<url>
<loc>https://rootjs.dev/fr/foo/</loc>
<xhtml:link rel="alternate" hreflang="x-default" href="https://rootjs.dev/foo/" />
<xhtml:link rel="alternate" hreflang="de" href="https://rootjs.dev/de/foo/" />
<xhtml:link rel="alternate" hreflang="es" href="https://rootjs.dev/es/foo/" />
<xhtml:link rel="alternate" hreflang="en" href="https://rootjs.dev/en/foo/" />
</url>
</urlset>
LMK if this looks good to you. (404.html is natively handled.)
@jeremydw thanks for the review!
Thanks for adding the feature 🔥
@jeremydw this is a sample output:
this look correct to you? the localized paths are added as "alts" to the "default locale route" and also as their own line item. there isn't currently a way to "noindex" routes, i can add that in a future update when the use case is needed.