Copied to clipboard

Flag this post as spam?

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


  • Emil Lindgren 28 posts 190 karma points
    Jul 08, 2019 @ 12:48
    Emil Lindgren
    0

    Sitemap as Global Node

    Hello, so i run into a problem, and hope some here can help me with it.

    Im working with siteMap.

    My siteMap works perfectly with 1 root node, but then my question come in.

    How can i make so that same siteMap as global and take two or more root nodes ?

    Look at picture. enter image description here

    This is some of my code.

            IPublishedContent siteHomePage = Umbraco.TypedContentAtRoot().First();
        var newurl = siteHomePage.Next();
    }<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.google.com/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">@RenderSiteMapUrlEntry(siteHomePage)@RenderSiteMapUrlEntriesForChildren(siteHomePage)</urlset>
    
    @helper RenderSiteMapUrlEntry(IPublishedContent node)
    {
       // we're passing 'true' as an additional parameter to GetPropertyValue to read the value from the parent nodes, so this setting could be set 'per section
       var changeFreq = node.GetPropertyValue<string>("searchEngineChangeFrequency", true);
       if (String.IsNullOrEmpty(changeFreq))
       {
          changeFreq = "monthly";
       }
       // with the relative priority, this is a per page setting, so we're not passing true
       var priority = node.GetPropertyValue<string>("searchEngineRelativePriority");
       if (String.IsNullOrEmpty(priority))
       {
          priority = "0.5";
       }
       <url>
          <loc>@EnsureUrlStartsWithDomain(node.UrlWithDomain())</loc>
          <lastmod>@(string.Format("{0:s}+00:00", node.UpdateDate))</lastmod>
          <changefreq>@changeFreq</changefreq>
          <priority>@priority</priority>
       </url>
    }
    
  • Søren Kottal 712 posts 4570 karma points MVP 6x c-trib
    Jul 08, 2019 @ 13:31
    Søren Kottal
    0

    Hi Emil

    Instead of having you sitemap as a node in the tree, you could go with just the template, and load that on your rootnodes.

    Say your template alias is Sitemap you can use that as the template for a node by using the url {nodeUrl}/sitemap.

    You would then need to change your siteHomePage in your template to be Model.Site() (or just Model, if you only want to use it on the root node).

  • Emil Lindgren 28 posts 190 karma points
    Jul 09, 2019 @ 06:39
    Emil Lindgren
    100

    Hello Sören, Thanks for the answer. So I'm not 100% with you here.

    so what you mean is that, i should load siteMap Template instead of my home template ?

    If you mean something else please elaborate.

Please Sign in or register to post replies

Write your reply to:

Draft