Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stefano 61 posts 313 karma points c-trib
    Mar 05, 2017 @ 10:14
    Stefano
    0

    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 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.

    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) to node.UpdateDate.ToString("s") + "+00:00". There is probably a more proper way to do it still.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies