Hannon Hill Cascade sitemaps

We run a few hundred sites through Hannon Hill Cascade CMS. For whatever reason, we never had sitemaps, so I wanted to fix that. This is the method we used.

We setup one site as a sort of Assets deposit. We’re in the process of moving all of our XSLT formats over there, as well as our frequently used content types, configuration sets, metadata sets, data defintions, etc. For this particular project, we setup a sitemap content type in this Assets site. There isn’t much to say about it:

Configuration Set

The configuration set is relatively basic, just an xml template that has a whopping one line:

<system-region name="DEFAULT"/>

and a single xslt format for the DEFAULT region:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:include href="site://AS-Dept-Assets/formats/format-date-code"/>
    <xsl:variable name="ext">.html</xsl:variable>
<xsl:template match="system-data-structure">
    <xsl:variable name="rootURL"><xsl:value-of select="url"/></xsl:variable>    
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
        <xsl:choose>
            <xsl:when test="sitemap-block != '/' ">
                <xsl:apply-templates select=".//system-page">
                    <xsl:with-param name="passing"><xsl:value-of select="$rootURL"/></xsl:with-param>
                </xsl:apply-templates>
            </xsl:when>
        </xsl:choose>
    </urlset>
</xsl:template>
<xsl:template match="system-page">
    <xsl:param name="passing"/>
    <url>
        <loc><xsl:value-of select="concat($passing,path,$ext)"/>
        </loc>
        <lastmod>
            <xsl:call-template name="format-date">
                <xsl:with-param name="date" select="last-modified"/>
                <xsl:with-param name="mask">yyyy-mm-dd</xsl:with-param>
            </xsl:call-template>
        </lastmod>
    </url>
</xsl:template>
</xsl:stylesheet>

It’s also setup to only publish in xml, with a .xml extension.

Data Definition

The Data Definition itself is also relatively short, we just need a single text field to grab the URL of the main site, and an index block with an absurdly high render-content-depth because you know, why not?

<system-data-structure>
    <text identifier="url" label="Primary URL" help-text="Please enter your full URL such as http://this.syr.edu"/>
    <asset type="block" identifier="sitemap-block" label="Sitemap Index Block" render-content-depth="50"/>
</system-data-structure>

The sitemap itself.

For each site that needs a sitemap, we first create an index block inside that site with the following settings:

  • Index Type: Folder Index
  • Index Folder: base folder
  • Depth of Index: 100 (or however much depth you actually need)
  • Max Rendered Assets: 0 (unlimited)
  • Indexed Asset Types: Pages
  • Rendering Behavior: Render normally, starting at the indexed folder
  • Indexed Asset Content: Regular Content, System Metadata, User Metadata, Folder Access Rights
  • Page XML: Do not render XML inline
  • Other Indexed Info: nothing
  • Sort Method: Folder Order is fine for our purposes
  • Sort Order: Ascending is fine for our purposes.

Save the block, make a page with outhe Content Type from our Assets site, and enter our base URL and select the block. Publish it out and we’re good.