How to add hreflang in Sitemap Generation #4317
Answered
by
brc-dd
chiaweilee
asked this question in
Q&A
-
https://developers.google.com/search/docs/specialty/international/localized-versions#sitemap e.g <?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">
<url>
<loc>https://www.example.com/english/page.html</loc>
<xhtml:link
rel="alternate" // 👈
hreflang="de" // 👈
href="https://www.example.de/deutsch/page.html"/>
<xhtml:link
rel="alternate"
hreflang="de-ch"
href="https://www.example.de/schweiz-deutsch/page.html"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="https://www.example.com/english/page.html"/>
</url>
<url>
<loc>https://www.example.de/deutsch/page.html</loc>
<xhtml:link
rel="alternate"
hreflang="de"
href="https://www.example.de/deutsch/page.html"/>
<xhtml:link
rel="alternate"
hreflang="de-ch"
href="https://www.example.de/schweiz-deutsch/page.html"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="https://www.example.com/english/page.html"/>
</url>
<url>
<loc>https://www.example.de/schweiz-deutsch/page.html</loc>
<xhtml:link
rel="alternate"
hreflang="de"
href="https://www.example.de/deutsch/page.html"/>
<xhtml:link
rel="alternate"
hreflang="de-ch"
href="https://www.example.de/schweiz-deutsch/page.html"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="https://www.example.com/english/page.html"/>
</url>
</urlset> |
Beta Was this translation helpful? Give feedback.
Answered by
brc-dd
Oct 28, 2024
Replies: 1 comment
-
If you're using i18n it should automatically work. Can you share your locales config? |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
chiaweilee
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're using i18n it should automatically work. Can you share your locales config?