: Is there a more efficient way to specify multiple languages for Google in a sitemap? According to this Google help document, we can create a sitemap telling Google that we have more than one
According to this Google help document, we can create a sitemap telling Google that we have more than one language. But this requires indicating each URL with different languages every time.
That means if you have one URL and three languages, you need to specify a <url> element with a <loc> tag and multiple <xhtml:link> subelements.
If you have twenty URLs and fifteen languages, you would then need ten <url> elements with 20*15^2 <xhtml:link> subelements. That equates to 4500 <xhtml:link> in the same sitemap.xml file, which is a lot!
For Example:
<?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>http://www.example.com/english/</loc>
<xhtml:link
rel="alternate"
hreflang="de"
href="http://www.example.com/deutsch/"
/>
<xhtml:link
rel="alternate"
hreflang="de-ch"
href="http://www.example.com/schweiz-deutsch/"
/>
<xhtml:link
rel="alternate"
hreflang="en"
href="http://www.example.com/english/"
/>
</url>
<url>
<loc>http://www.example.com/deutsch/</loc>
<xhtml:link
rel="alternate"
hreflang="en"
href="http://www.example.com/english/"
/>
<xhtml:link
rel="alternate"
hreflang="de-ch"
href="http://www.example.com/schweiz-deutsch/"
/>
<xhtml:link
rel="alternate"
hreflang="de"
href="http://www.example.com/deutsch/"
/>
</url>
<url>
<loc>http://www.example.com/schweiz-deutsch/</loc>
<xhtml:link
rel="alternate"
hreflang="de"
href="http://www.example.com/deutsch/"
/>
<xhtml:link
rel="alternate"
hreflang="en"
href="http://www.example.com/english/"
/>
<xhtml:link
rel="alternate"
hreflang="de-ch"
href="http://www.example.com/schweiz-deutsch/"
/>
</url>
</urlset>
Is there a better practice for this?
More posts by @Hamaas447
2 Comments
Sorted by latest first Latest Oldest Best
No this is the only way to define ahref lang tags in an xml sitemap.
Rather that defining the ahref lang tags in an xml sitemap file, would it be easier if you defined them in the source code of the page?
e.g
on www.example.com/english/ you would have the following tags within the section of the code
<link rel="alternate" www.example.com/english/ hreflang="en" />
<link rel="alternate" www.example.com/french/ hreflang="fr" />
<link rel="alternate" www.example.com/german/ hreflang="de" />
on www.example.com/french/ you would have the following tags within the section of the code
<link rel="alternate" www.example.com/english/ hreflang="en" />
<link rel="alternate" www.example.com/french/ hreflang="fr" />
<link rel="alternate" www.example.com/german/ hreflang="de" />
on www.example.com/german/ you would have the following tags within the section of the code
<link rel="alternate" www.example.com/english/ hreflang="en" />
<link rel="alternate" www.example.com/french/ hreflang="fr" />
<link rel="alternate" www.example.com/german/ hreflang="de" />
Similar to in the sitemap, you need to add a tag for the page itself and all the other language versions. But depending on your set up, this might be easier than in an xml sitemap?
I'd like to increase compatibility of my sitemaps to as many search engines as possible. For this reason, I'd like to only insert my URLs between <loc> and </loc> only. For example:
<loc>http://www.example.com/english/</loc>
<loc>http://www.example.com/french/</loc>
<loc>http://www.example.com/german/</loc>
Also, I'd define the language when each URL is accessed in the following ways:
Using the content-language HTTP header. For example: Content-Language: da
adding the lang attribute to the HTML tag. For example: <html lang="da">
There is also an accept language header that tells you what languages the client (including google) accepts when scanning your page if the client specifies any. That way you won't have google index pages in languages it does not support.
Here's more info on the HTTP headers:
en.wikipedia.org/wiki/List_of_HTTP_header_fields
Here's more info on the attributes that can be applied to the HTML tag:
www.w3schools.com/tags/ref_language_codes.asp
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.