You need to sign in to do that
Don't have an account?
Trace 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>
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>
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:
Please mark this answer as the best one if it solves the problem.