function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Trace GillespieTrace Gillespie 

XML Sitemap alternate language pages - Error: Unknown component xhtml:link

I'm trying to save an xml sitemap with multiple language suppport added like Google suggests here (https://support.google.com/webmasters/answer/2620865?hl=en&ref_topic=2370587), however my Force.com IDE and even the page editor will not let me save my changes. 

Here's my file:

<apex:page contentType="text/xml">

<urlset
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
      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>http://www.test.com/</loc>
  <xhtml:link rel="alternate" hreflang="en-us" href="http://www.test.com/"/>
  <xhtml:link rel="alternate" hreflang="en-ca" href="http://www.test.ca/en"/>
  <xhtml:link rel="alternate" hreflang="de-de" href="http://www.test.com/de"/>
  <xhtml:link rel="alternate" hreflang="fr-fr" href="http://www.test.com/fr"/>  
</url>

</urlset>

</apex:page>
Best Answer chosen by Trace Gillespie
Matt Remy SFDCMatt Remy SFDC
Hi Trace,

The SFDC compiler interprets the ":" in "<xhtml:link" as a call to a VisualForce component. As the component doesn't exist, it throws this error. Problem of course is that Google doesn't care about Salesforce syntax and likes its <xhtml:link notation.

You need to use another notation to circumvent the problem. Actually, "<xhtml:link" is a short-hand notation for <link xmlns="http://www.w3.org/1999/xhtml" 

So a solution is just to replace the short-hand notation by the long notation.

Besides, if I may, there are 2 other issues in your code that Google crawler may not like.

First your urlset definition should be <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">

Then, for each url, it is best practice to define the default one by adding a link tag for each url.

So, all in all, this code should work better or you:
<apex:page contentType="text/xml">
	<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
	<url>
		  <loc>http://www.test.com/</loc>
		  <link xmlns="http://www.w3.org/1999/xhtml" rel="alternate" hreflang="x-default" href="http://www.test.com/"/>
		  <link xmlns="http://www.w3.org/1999/xhtml" rel="alternate" hreflang="en-us" href="http://www.test.com/"/>
		  <link xmlns="http://www.w3.org/1999/xhtml" rel="alternate" hreflang="en-ca" href="http://www.test.ca/en"/>
		  <link xmlns="http://www.w3.org/1999/xhtml" rel="alternate" hreflang="de-de" href="http://www.test.com/de"/>
		  <link xmlns="http://www.w3.org/1999/xhtml" rel="alternate" hreflang="fr-fr" href="http://www.test.com/fr"/>  
		</url>
	</urlset>
</apex:page>

Please mark this answer as the best one if it solves the problem.