News blog post to be added to sitemap automatically

Feb 20, 2011 at 12:33 PM

Hi all,

I'm learning C1 and I think it is a great CMS. 

My understanding is that the Blog module will not add URL to the sitemap. Compared to other CMS, it will leads us to disadvantages in term of SEO. Is there any plan to add this functionality?

Cheers,

Philip

 

Feb 20, 2011 at 4:30 PM
Edited Feb 20, 2011 at 4:32 PM

Since the SitemapNavigator simply reflects over IPageStructure and IPage its not dynamic in any way, and can only know about "real" pages, and not extra data elements. All ChildPages properties only return IEnumerables as well so its not possible to add anything to them.

Using the SiteMapProvider from http://compositec1contrib.codeplex.com its possible to dynamically add new nodes to a node object, lets say


var blogPage = SiteMap.Provider.FindSiteMapNodeFromKey(some_guid);
foreach (var blogPost in data.GetBlogPosts)
{
   var blogPostNode = new SiteMapNode(SiteMap.Provider, blogPost.ID, blogPage.Url +"?id="+ blogPost.ID, blogPost.Title);

   blogPage.ReadOnly = false;
   blogPage.ChildNodes.Add(blogPostNode);
   blogPage.ReadOnly = true;
}

This would easiest be done by subclassing CompositeSiteMapProvider and overriding LoadSiteMapInternal to do this special blog-post logic after calling base.LoadSiteMapInternal, to make sure we have all these extra nodes each time the sitemap is being flushed or needs reloading.