One of the must do tasks for any webmaster is the creation and
submission of a sitemap to Google. Submitting a sitemap doesn't
guarantee that all the pages in your site will be indexed, however
it does make it easier for the search engines to at least find your
content, which is particularly important if your site is not
structured in a SEO friendly manner.
There are a number of packages in the umbraco forum for creating
Google sitemaps, however in this article I will show you how to
make your own which we will modify in future articles to form the
basis of a News Sitemap and a Video Sitemap.
The google article on creating and submitting
sitemaps can be found here.
Step 1
The first step in umbraco is to create a new document type and
matching template which we will call "Google Sitemap". Add
one new property to this doc type with an alias of umbracoNaviHide
and use the "True/False" datatype.
Step 2
Create a new XSLT file called "Google Sitemap" and paste the
following code. Please note that this code initially came
from someone in the umbraco community, however I don't know who so
I can't reference them here, also the domain name is hard coded in
two locations below which you will need to update.
<xsl:template match="/">
<!-- rendering first level node -->
<url>
<loc>/</loc>
</url>
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent"
select="$currentPage/ancestor-or-self::node [@level=1]"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="drawNodes">
<xsl:param name="parent"/>
<xsl:if test="umbraco.library:IsProtected($parent/@id,
$parent/@path) = 0
or (umbraco.library:IsProtected($parent/@id,
$parent/@path) = 1
and umbraco.library:IsLoggedOn()
= 1)">
<xsl:for-each select="$parent/node [string(./data
[@alias='umbracoNaviHide']) != '1'
and @level <=
$maxLevelForSitemap]">
<url>
<loc><xsl:value-of
select="umbraco.library:NiceUrl(@id)"/></loc>
</url>
<xsl:if test="count(./node [string(./data
[@alias='umbracoNaviHide']) != '1'
and @level <=
$maxLevelForSitemap]) > 0">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="."/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:template>
Step 3
Open the Google Sitemap template created in step 1 and paste in
the following code.
<%@ Master Language="C#"
MasterPageFile="/umbraco/masterpages/default.master"
AutoEventWireup="true" %><asp:Content
ContentPlaceHolderID="ContentPlaceHolderDefault"
runat="server"><?xml version='1.0'
encoding='UTF-8'?><urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><umbraco:Macro
Alias="GoogleSitemap"
runat="server"></umbraco:Macro></urlset></asp:Content>
Step 4
The final step is to go into the content tree and create a new
file. This can be called anything you want, however you will
need to note the filename so you can submit it through webmaster
tools. If you don't have the option of "Google Sitemap" as a
valid child node, check to ensure that the parent document type
allows the "Google Sitemap" doctype as a child node.