Copied to clipboard

Flag this post as spam?

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

  • Streety 358 posts 568 karma points
    Jan 05, 2017 @ 12:43

    Ameded to pickup recursive Change Frequency & Priority

    Made a slight change so that Change Frequency & Priority were enabled by default.


    Add two new properties at the root or similar on your site. Change Frequency & Priority

    ...with the values stated in the release notes. I used a standard dropdown list.

    In Umbraco set the default values in that high level node.


    Update the Sitemap template cshtml file with this.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{Layout = null;}<?xml version="1.0" encoding="UTF-8" ?>
    <urlset xmlns=""
    @helper ListChildNodes(IPublishedContent startNode)
        Response.ContentType = "text/xml";
        const int maxLevelForSiteMap = 100;
        foreach(var node in startNode.Children
                        .Where(n => n.TemplateId > 0 && !Umbraco.IsProtected(n.Path))
                        .Select(n => n.AsDynamic() )
        @if (node._SearchEngineSitemapChangeFreq.ToString() != ""){<changefreq>@node._SearchEngineSitemapChangeFreq</changefreq>}
        @if (node._SearchEngineSitemapPriority.ToString() != ""){<priority>@node._SearchEngineSitemapPriority</priority>}
        if (node.Level <= maxLevelForSiteMap)


    That's it. Change freq and priority are added automatically with default values until changed in the actual content page.

    Of Note:

    The script will return nothing unless a template is assigned to the content.

    n.TemplateId > 0

    Which makes perfect sense, however please note that if you have content as children which DO have templates associated BUT the parent doesn't, the recurse ability will stop, and you will need to amend the script to check of children with templates first.

    many thanks for writing.

Please Sign in or register to post replies

Write your reply to: