You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When generating a sitemap for a Next.js application with multiple languages we incorrectly generates the hreflang attributes in the sitemap XML. It seems to have a limitation or bug in how it handles the alternateRefs array when generating the sitemap XML. The package is not correctly using the href values from the alternateRefs array and is instead using the original URL path for all hreflang entries.
To Reproduce
Define a custom transform function that generates alternateRefs array for each URL using a bunch of constants specifying the correct hreflang and href values for each alternate language
generate sitemap
Inspect sitemap
(code below)
In the generated sitemap XML, the xhtml:link elements for alternate language URLs should have the correct hreflang and href attributes. The href attribute should contain the appropriate URL for each alternate language, matching the hreflang value.
In the generated sitemap XML, the xhtml:link elements for alternate language URLs have incorrect href attributes. The href attribute contains the same URL as the main URL, instead of the corresponding alternate language URL.
For example, for a URL like https://example.com/fr/blog, the actual xhtml:link elements in the sitemap XML are:
markojak
changed the title
Bug: Not using href values from alternaateRefs array and instead original URL path for all hreflang entries
Not using href values from alternaateRefs array and instead original URL path for all hreflang entries
Apr 9, 2024
I haven't tested this yet, but since hreflang is defined appropriately, did you consider the fact that your regex might be incorrect/returns something different then you'd expect? Since this is a custom transformation, I would assume that something is going wrong in the transformation and that it hasn't got much to do with the package itself
Describe the bug
When generating a sitemap for a Next.js application with multiple languages we incorrectly generates the
hreflang
attributes in the sitemap XML. It seems to have a limitation or bug in how it handles the alternateRefs array when generating the sitemap XML. The package is not correctly using the href values from the alternateRefs array and is instead using the original URL path for all hreflang entries.To Reproduce
(code below)
In the generated sitemap XML, the xhtml:link elements for alternate language URLs should have the correct hreflang and href attributes. The href attribute should contain the appropriate URL for each alternate language, matching the hreflang value.
For example, for a URL like https://example.com/fr/blog, the expected xhtml:link elements should be:
Actual behavior
In the generated sitemap XML, the xhtml:link elements for alternate language URLs have incorrect href attributes. The href attribute contains the same URL as the main URL, instead of the corresponding alternate language URL.
For example, for a URL like https://example.com/fr/blog, the actual xhtml:link elements in the sitemap XML are:
Additional context
Next.js version: "next": "13.4.10-canary.1",
Latest sitemap version
Implementation
The text was updated successfully, but these errors were encountered: