Starting from DNN 7.2.2, it was added an alternate link with "hreflang" to sitemap.aspx for multilingual websites. However this does not seems to work even in the latest DNN 8.0.4 released on the 17th of August 2016.
After digging into the sitemap provider source code (from the source code related to the latest release) I found that the following lines in SitemapBuilder.cs that should add the alternate link to the sitemap are commented out:
private void AddURL(SitemapUrl sitemapUrl)
{
writer.WriteStartElement("url");
writer.WriteElementString("loc", sitemapUrl.Url);
writer.WriteElementString("lastmod", sitemapUrl.LastModified.ToString("yyyy-MM-dd"));
writer.WriteElementString("changefreq", sitemapUrl.ChangeFrequency.ToString().ToLower());
writer.WriteElementString("priority", sitemapUrl.Priority.ToString("F01", CultureInfo.InvariantCulture));
//if (sitemapUrl.AlternateUrls != null)
//{
// foreach (AlternateUrl alternate in sitemapUrl.AlternateUrls)
// {
// writer.WriteStartElement("link", "http://www.w3.org/1999/xhtml");
// writer.WriteAttributeString("rel", "alternate");
// writer.WriteAttributeString("hreflang", alternate.Language);
// writer.WriteAttributeString("href", alternate.Url);
// writer.WriteEndElement();
// }
//}
writer.WriteEndElement();
}
To be sure I also inspected the released DotNetNuke.dll with .Net Reflector just to find that AddURL() method is missing the lines devoted to the creation of the alternate links:
private void AddURL(SitemapUrl sitemapUrl)
{
this.writer.WriteStartElement("url");
this.writer.WriteElementString("loc", sitemapUrl.Url);
this.writer.WriteElementString("lastmod", sitemapUrl.LastModified.ToString("yyyy-MM-dd"));
this.writer.WriteElementString("changefreq", sitemapUrl.ChangeFrequency.ToString().ToLower());
this.writer.WriteElementString("priority", sitemapUrl.Priority.ToString("F01", CultureInfo.InvariantCulture));
this.writer.WriteEndElement();
}
So the question is why are these lines commented out? I couldn't find any reported bug on dnntracker.atlassian.net to justify the commented lines.
Is anyone aware of this (mind that uncommenting the lines and recompiling the library generates a correct sitemap) and the reason why the lines have been removed?
It's important to mention that the last version of SitemapBuilder.cs in github actually have the above lines uncommented.
Thank you to anyone for answering my question.