Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kyle Skrinak 272 posts 327 karma points
    Aug 06, 2009 @ 15:57
    Kyle Skrinak
    1

    Creating a sitemap.xml for my site

    I see this page:

    Umbraco/Samples and Articles/XSLT

    but I need a very basic explanation for creating the root/sitemap.xml file.

    Thanks!

  • Richard Soeteman 4054 posts 12927 karma points MVP 3x
    Aug 06, 2009 @ 16:09
    Richard Soeteman
    1

    Hi,

    I've used this Search Engine Package to create sitemaps. You can see how it works by viewing the xslt's

    Hope it helps you,

    Richard

  • dandrayne 1138 posts 2262 karma points
    Aug 06, 2009 @ 16:23
    dandrayne
    0

    Also the CWS has sitemap xslt in it which works great

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 12x admin c-trib
    Aug 06, 2009 @ 16:24
    Jan Skovgaard
    0

    Hi Kyle

    You could also use the predefined sitemap XSLT, which is alreday available in the umbraco developer section. Probably one that is similar to the one you refer to in the old wiki.

    Then just replace the html elements with the xml elements you need and make a template with the XML prologue <?xml version="1.0" encoding="UTF-8"?> and after that call your macro. Assign the template to a documenttype and create a node in the content section where you choose your XML template.

    Hope this gives some inspiration.

    /Jan

  • Kyle Skrinak 272 posts 327 karma points
    Aug 06, 2009 @ 19:48
    Kyle Skrinak
    0

    @Richard: thanks for the recommendation; I saw that too, but I was hoping to make one without an additional package. That is my fall-back.

    @dandryane: Thanks, also. I considered unpacking the CWS to reverse-engineer it but that might be costly timewise? Or, perhaps I could do so at that the autoumbraco.darren-ferguson.com site? Checking that out now.

    @Jan: Much much thanks -- I think I'll see if I can combine your instructions with what I see at the auto site to make my own

    Awesome community -- thanks everyone!

  • Kyle Skrinak 272 posts 327 karma points
    Aug 06, 2009 @ 20:38
    Kyle Skrinak
    0

    OK, stumbling towards success here.

    I have copied all the info from the CWS at the autoumbraco site to my site. There are some interesting differences in the xslt files, as if I were qualified to make such a statement.

    Anyhow, I have a sitemap.aspx page now, referencing a sitemap document, which references a sitemap template which references a sitemap macro. However I'm not getting a complete sitemap. Here's the source code on a rendered page:

    <?xml version="1.0" encoding="utf-16"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>http://www.correcturl.com/</loc><changefreq>daily</changefreq><lastmod>2009-08-06T14:11:11+00:00</lastmod><priority>1</priority></url></urlset>

    I'm using all the same data that is in the CWS site, at least the one at autoumbraco

    Thanks!

  • Jan Skovgaard 11280 posts 23678 karma points MVP 12x admin c-trib
    Aug 06, 2009 @ 20:49
    Jan Skovgaard
    0

    Do you have a $level variable somewhere you can set to a greater number perhaps?

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Aug 06, 2009 @ 21:39
    Sebastiaan Janssen
    0

    Kyle, my package really only contains an xslt (don't be afraid, it was made lean and mean especially for people who don't like installing "extra stuff"), here's the source, feel free to use it:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary ">

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:variable name="urlPrefix">http://<xsl:value-of select="umbraco.library:RequestServerVariables('HTTP_HOST')" /></xsl:variable>

    <!-- update this variable on how deep your site map should be -->
    <xsl:variable name="maxLevelForSitemap" select="6"/>

    <xsl:template match="/">
    <!-- change the mimetype for the current page to xml -->
    <xsl:value-of select="umbraco.library:ChangeContentType('text/xml')"/>

    <xsl:call-template name="drawNodes">
    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node [@level=1]"/>
    </xsl:call-template>
    <!-- </urlset> -->
    </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 &lt;= $maxLevelForSitemap]">

    <!-- If the document does not have a template, nothing is shown in the frontend anyway.
    So this is not proper content and should not be in the sitemap -->
    <xsl:if test="@template &gt; 0">
    <url>
    <loc><xsl:value-of select="$urlPrefix" /><xsl:value-of select="umbraco.library:NiceUrl(@id)" /></loc>
    <lastmod><xsl:value-of select="umbraco.library:FormatDateTime(@updateDate, 'yyyy-MM-ddThh:mm:ss+00:00')" /></lastmod>
    <xsl:if test="./data [@alias='searchEngineSitemapChangeFreq'] != ''">
    <changefreq><xsl:value-of select="./data [@alias='searchEngineSitemapChangeFreq']" /></changefreq>
    </xsl:if>
    <xsl:if test="./data [@alias='searchEngineSitemapPriority'] != ''">
    <priority><xsl:value-of select="./data [@alias='searchEngineSitemapPriority']" /></priority>
    </xsl:if>
    </url>
    </xsl:if>

    <xsl:if test="count(./node [string(./data [@alias='umbracoNaviHide']) != '1' and @level &lt;= $maxLevelForSitemap]) &gt; 0">
    <xsl:call-template name="drawNodes">
    <xsl:with-param name="parent" select="."/>
    </xsl:call-template>
    </xsl:if>

    </xsl:for-each>
    </xsl:if>
    </xsl:template>

    </xsl:stylesheet>
  • Kyle Skrinak 272 posts 327 karma points
    Aug 06, 2009 @ 22:43
    Kyle Skrinak
    0

    @Jan: There's this line which I guess you're referrng to?:

    <xsl:variable name="maxLevelForSitemap" select="6"/>

    @Sebastiaan: I copied your xslt into my xslt file; but I get an error: 

    This page contains the following errors:

    error on line 1 at column 1: Extra content at the end of the document

    Below is a rendering of the page up to the first error.

    There are no error messages in my umbraco error log.

    Thanks!

  • Kyle Skrinak 272 posts 327 karma points
    Aug 06, 2009 @ 22:45
    Kyle Skrinak
    0

    One other thing -- the xslt in the autoumbraco CWS site works fine.

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Aug 06, 2009 @ 22:55
    Sebastiaan Janssen
    0

    Kyle: I was wondering where the error came from, but I realize it's probably Google right?

    I put the sitemap macro in a clean template / master page that looks like this, should help (careful if you add extra line breaks, it will not work):

    <%@ 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="CultivSearchEngineSitemap" runat="server"></umbraco:Macro>
    </urlset>
    </asp:Content>
  • Kyle Skrinak 272 posts 327 karma points
    Aug 07, 2009 @ 16:26
    Kyle Skrinak
    0

    @Sebastiaan;

    I used your package to add a site map. The functionality of the package promises to be very handsome; thanks for your hard work. However, I'm not getting any nodes rendered. Here is the source output from the sitemap node:

    <?xml version='1.0' encoding='UTF-8'?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

    </urlset>

    The CultivSearchEngineSitemap node is published as a child from the content root. All other nodes reside in folders, sorted by language, i.e.,

    Content:
    |
    |
    |--sitemap.aspx
    |--EN (folder)
    | |-- pageone
    | |-- pagetwo
    |--CN (folder)
    |--(and so on)

    Thanks!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies