I wrote a generator for XML sitemap for SEO purposes and deployed to a number of websites. It relies on this package https://our.umbraco.org/projects/backoffice-extensions/seo-metadata-for-umbraco/ and a couple of fields (sitemapXmlPriority and sitemapXmlChangeFrequency) to fill in all the data.
I recommend having a root document type for your public-facing pages with those in so that they get inherited by the other pages.
Response.Write(@"<?xml version=""1.0"" encoding=""UTF-8"" ?>"); seems dirty, but in one instance a website was adding an empty line and couldn't find the reason for it, this makes sure it doesn't happen and the XML validates.
If you don't have C# 6 installed you can change string.Format("{0:s}+00:00", node.UpdateDate) to node.UpdateDate.ToString("s") + "+00:00". There is probably a more proper way to do it still.
My sitemap xml generator
I wrote a generator for XML sitemap for SEO purposes and deployed to a number of websites. It relies on this package https://our.umbraco.org/projects/backoffice-extensions/seo-metadata-for-umbraco/ and a couple of fields (
sitemapXmlPriority
andsitemapXmlChangeFrequency
) to fill in all the data. I recommend having a root document type for your public-facing pages with those in so that they get inherited by the other pages.https://gist.github.com/StefanoChiodino/da7e76e8ca87951623e06fcfb5df3df4
Notes:
Response.Write(@"<?xml version=""1.0"" encoding=""UTF-8"" ?>");
seems dirty, but in one instance a website was adding an empty line and couldn't find the reason for it, this makes sure it doesn't happen and the XML validates.If you don't have C# 6 installed you can change
string.Format("{0:s}+00:00", node.UpdateDate)
tonode.UpdateDate.ToString("s") + "+00:00"
. There is probably a more proper way to do it still.is working on a reply...