Closed seifertm closed 5 years ago
Thanks!
Thank you for taking care of this so quickly! Looking forward to the next release :)
I'd also be willing to provide test cases for this PR, if you intend to add automated tests at some point. Just ping me.
That's great!
Eh, I invited you as collaborator as I am busy this month.
Consider the following vuepress page with the default locale
en
located at/
and a second localede
located at/de/
:Currently, vuepress-plugin-sitemap will generate the following sitemap entry:
However, Google is unhappy with this, because the hreflang links reference pages that have no back reference in the sitemap. Google notifies webmasters about a problem in their sitemap. Please refer to the corresponding Google support page on this topic.
This PR ensures that each hreflang references an existing location in sitemap. For our example page, the sitemap will look like this:
The new code iterates over all pages and normalizes their URL by stripping the locale's prefix from the URL. The loop builds a map with the normalized URL as a key and a list of locale prefixes as value. When sitemap data is assembled in
pageMap
, the mapping used to determine the hreflang links for the current page.