Sitemap.Xml - Sitemap generator

  0 rating
7/25/2015 12:24:03 AM
10/28/2015 9:49:55 AM
Source: GitHub
Provider: Linakis Digital

About

This module helps you automatically generate your website's sitemap.xml file based on your content.

Basic Features
  • Multiple managed website support
  • Can be fully customized using pipelines
  • Out of the box behavior utilizes Lucene to index your content

Documentation

Documentation
  • Documentation > INSTALLATION
    INSTALLATION

    Install the module as usual, using Sitecore's Installation Wizard.

    To enable the module, you need to edit web.config and, depending on your IIS version and application pool mode, add the following lines:

    • In system.webServer/handlers: <add verb="GET" path="sitemap.xml" type="LD.Sitemap.Xml.SitemapHandler, Sitemap.Xml" name="LD.Sitemap.Xml"/>
    • In system.web/httpHandlers: <add verb="GET" path="sitemap.xml" type="LD.Sitemap.Xml.SitemapHandler, Sitemap.Xml"/>
    0
  • Documentation > CONFIGURATION
    CONFIGURATION

    For the module to be useful, you need to edit /App_Config/Include/Sitemap.Xml.config and add a /configuration/sitecore/sitemap/sites/site node for each of your managed websites that you wish to automatically produce a sitemap.xml file. There is an example (dummy) such section for the "website" managed website that comes by default with Sitecore. Your "site" node must have a "name" attribute that matches exactly your managed website's name. Also, an "embedLanguage" boolean attribute is supported, which dictates whether the language gets embedded in the produced sitemap nodes (see the "Functionality" section).

    The site node supports the following subnodes (check out the example configuration for a template):

    • <includedTemplates> - the module indexes all items whose template ID matches exactly one of the GUIDs in this list;
    • <includedBaseTemplates> - the module indexes all items whose template ID, or one or more of their base templates' ID, matches exactly one of the GUIDs in this list;
    • <excludedItems> - the module excludes from indexing all items whose item ID matches exactly one of the GUIDs in this list.
    1
  • Documentation > FUNCTIONALITY
    FUNCTIONALITY

    When a request is made for /sitemap.xml, the IIS handler you configured in the installation step first searches for a configuration section for a site whose name matches the currently resolved managed website's name. If such a section is not found, a 404 status code is returned. Otherwise, it runs the "createSitemapXml" pipeline. This pipeline is also defined in Sitemap.Xml.config. Out of the box it runs only one processor, namely "LD.Sitemap.Xml.Pipelines.DefaultSitemapXmlProcessor". This processor proceeds as follows:

    1. Checks if it's been given an index name as an argument;
    2. if yes, it uses this index, otherwise it uses the index determined by the index resolver for the managed website's start item;
    3. searches this index for all items matching the included template/excluded items configuration in all languages if the "embedLanguage" attribute is true, or in the context language if the attribute is false;
    4. adds the found items to the result.

    Finally, the sitemap.xml handler writes all the combined results from all pipeline processors to the output stream, in valid sitemap.xml format. If the "embedLanguage" attribute is true then the output results contain the language embedded in the URL, otherwise they do not.

    Note that if you choose to use the default pipeline processor, you must enable the "_templates" index field in your index configuration, otherwise the included base templates will not work.

    You are free to patch-replace or add your own pipeline processors, e.g. in cases where you need to index data external to your Sitecore content, or if you wish to use a different strategy rather than the Lucene indexing mechanism. See the code examples section for an example of a (rather dull) pipeline processor.

    2
Back
Release notes
- v1.1 (September 18, 2015)
- Initial release (July 24, 2015)
Read more Back
Code examples
  • Code examples > A createSitemapXml pipeline processor
    A createSitemapXml pipeline processor

    The following pipeline processor simply outputs 10 random URLs.

    namespace LD.Test
    {
      using LD.Sitemap.Xml.Pipelines;
      using System;

      public class DummySitemapProcessor : CreateSitemapXmlProcessor
      {
      public override void Process(CreateSitemapXmlArgs args)
      {
          var rng = new Random();
          for (var i = 0; i < 10; i++)
          {
            args.Nodes.Add(new UrlDefinition(string.Format("http://www.linakis.com/{0}.html", rng.Next()), DateTime.Now);
          }
        }
      }
    }

    3

Solution screenshots(0)

Upload

Reviews (0)

Sort by: Date Most votes
  • Profile Avatar
    [fullName]

    Level: 0

    x0 x0 x0

    [date]

    [title]

    [text]

    Was this helpful?

    0

Comments (0)

Sort by: Date  Most votes

Leave a Comment

Comment must be field in
Post comment
loader

Write a review

Title can't be empty
Review can't be empty
Post review

Download

Title Description Download Action

Add File