DNN 5 Google Sitemaps Broken

Jack Simpson

Head of Marketing and Communications

I know it was you, Fredo.

One of the things that attracted me to DNN was the numerous modules that purported to improve SEO.  Unfortunately, there’s no such thing as free SEO, it’s just a painful slog of trying to follow best practices everywhere you can, but every now and then something throws a spanner in the works.

I’ve come across Google Sitemaps and the sitemap specification frequently over the years, and for some reason it always seems to be harder than it should be, especially considering the volume of XML expertise Babel has given me over the last few years.  The reality is, it all comes down to namespaces as always, a great idea, just never particularly well implemented, it seems to catch everyone out.

Anyway, it didn’t really come as a surprise to see my newly submitted sitemap rejected by Google on the first attempt, and sure enough the culprit can be found in the new code in DNN 5 for sitemap generation.  You can see our corrected sitemap at /sitemap.aspx, if you’re interested.

The existing code incorrectly sets the header xsi:schemaLocation attribute on the urlset node.  This can be corrected by navigating to BuildSiteMap sub-routine in sitemap.aspx and changing the build header lines to read the following:

   1: ' build header

   2: writer.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9")

   3: writer.WriteAttributeString("xmlns", "xsi", Nothing, "http://www.w3.org/2001/XMLSchema-instance")

   4: writer.WriteAttributeString("xsi", "schemaLocation", Nothing, "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd")            

   5: ' URL Attribute Not Supported - writer.WriteAttributeString("", "url", Nothing, "http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd")

(NB You search for the ‘build header’ comment, and make the modifications above)

Before wasting your time submitting to Google I highly recommend using the Google sitemap validator, as Google can take upwards of an hour to recheck your submitted sitemaps.  Once you get the result you’re looking for re-submit to Google, and you’re one step closer to better rankings.

Sitemap finally submitted.