Adds dynamic sitemap functionality to a Cofoundry site
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Updated to Cofoundry 0.6 Jan 4, 2019
.gitattributes Initial commit Sep 20, 2016
.gitignore
GitVersion.yml Updated to stable Cofoundry package, set up new CI with pre-releases … Feb 20, 2017
LICENSE Copyright update Jan 2, 2019
README.md Updated urls for cofoundry.org Feb 17, 2017
appveyor.yml Package update and 0.2 release Feb 22, 2018
build.cake Copyright update Jan 2, 2019
build.ps1 Initial commit Sep 20, 2016

README.md

Cofoundry.Plugins.SiteMap

Build status NuGet Gitter

This library is a plugin for Cofoundry. For more information on getting started with Cofoundry check out the Cofoundry repository.

Overview

Sitemaps are an easy way for webmasters to inform search engines about pages on their sites that are available for crawling. In its simplest form, a Sitemap is an XML file that lists URLs for a site along with additional metadata about each URL

sitemaps.org

The SiteMap plugin is a quick and easy way to add a dynamic sitemap to your site. All pages and custom entities routes are added to the sitemap automatically and additional pages can be added easily using an ISiteMapResourceRegistration class.

The sitemap is located at /sitemap.xml

Custom Site Map Pages

If you have standard MVC routes or have a SPA app that handles routing on the client side you'll have to add these routes to the sitemap manually. You can add items to the sitemap by creating a class that implements ISiteMapResourceRegistration or IAsyncSiteMapResourceRegistration, which will automatically be picked up and registered with the sitemap:

using Cofoundry.Plugins.SiteMap;

public class SiteMapRegistration : ISiteMapResourceRegistration
{
    public IEnumerable<ISiteMapResource> GetResources()
    {
        yield return new SiteMapResource("/");
        yield return new SiteMapResource("/blog");
        yield return new SiteMapResource("/about");
    }
}

If you want to dynamically generate a collection of links from a data source asynchronously you can instead implement IAsyncSiteMapResourceRegistration. Constructor dependency injection is supported.

Customizing The Site Map XML File

For more control over how the sitemap xml file is rendered you should override the default ISiteMapBuilderFactory implementation (override via DI) to return a custom ISiteMapBuilder, which will give you full control of the output.