Coder Social home page Coder Social logo

cofoundry.plugins.sitemap's Introduction

Cofoundry.Plugins.SiteMap

Build status NuGet

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.

cofoundry.plugins.sitemap's People

Contributors

heyjoel avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

cofoundry.plugins.sitemap's Issues

Mistake in priority calculation

Hello,

It seems there is a mistake in the file : Cofoundry.Plugins.SiteMap.CofoundryContentSiteMapResourceRegistration

    private decimal GetPriority(PageRoute pageRoute)
    {
        var isDirectoryDefaultPage = pageRoute.IsDirectoryDefaultPage();
        var isInSiteRoot = pageRoute.PageDirectory.IsSiteRoot();

        // Site/Language root
        if (isDirectoryDefaultPage && isDirectoryDefaultPage) return 1;
        // Directory root
        if (isDirectoryDefaultPage) return 0.8m;

        // Directory sub pages
        return 0.6m;
   }

I think it would be :
if (isInSiteRoot && isDirectoryDefaultPage) return 1;

Regards

Bad format of priority in not US culture

Hello,
When we are not in US culture, the priority can be in a bad format: in fr-FR for instance, it is with a comma instead of a point.
Could you force the culture to invariant culture in order to prevent this problem?
Thanks

Sitemap not updating

Hi I've added the sitemap nuget package to my Cofoundry project.
Navigating to /sitemap.xml shows all the correct adresses for my pages however I have one problem:

The last modified date is the date of when the page was created, modifying this page (i.e. adding additional content to the page via page blocks) does not update this date.

Is this the intentional way the package should behave or did I miss some implementation?

This is a problem for me as SERPs can use the sitemap.xml file to know if a site has been updated or not, something that's rather important for blogs.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.