Looking for old forum posts and information? View the old forum archive here ยป
Welcome to Vortx Community Forum, where you can ask questions and receive answers from the staff at Vortx and other members of the community.

If you had a user account on our previous forums website, you will need to register a new account here.

A static copy of our previous forums website is available online for reference. Click here to access the forum archive.

Learn more about...


Canonical Link Url

How would I go about changing the code below, so that it will take into account category pages, etc?

Does anyone have a solution for getting canonical urls? 

Thanks in advanced

Side note; we are running version 10.0.2

xml package (canonical.config.xml) with the following:

<?xml version="1.0" standalone="yes" ?>

<package version="2.1" displayname="Canonical Links" debug="true" includeentityhelper="true">
        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                        xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
          <xsl:output method="xml" omit-xml-declaration="yes" />
                <xsl:template match="/">
                <xsl:param name="site">http://www.localhost/pccom/</xsl:param>
                  <link rel="canonical">
                    <xsl:attribute name="href">
                        <xsl:value-of select="$site"/>p-<xsl:value-of select="/root/RunTime/PageID"/><xsl:value-of select="/root/QueryString/searchenginename"/><xsl:text>.aspx</xsl:text>


The above code will return the correct url when on a product page, which is fine

<link rel="canonical" href="http://www.localhost/pccom/p-graco-ultra-395-airless-paint-sprayer-special.aspx">


I've tried adding the following conditions to take into account for category pages, etc. However this doesn't return anything.

			<xsl:param name="canonical">
                    <xsl:when test="/root/RunTime/PageType = 'category'"><xsl:value-of select="$site"/>c-<xsl:value-of select="/root/RunTime/PageID"/>-<xsl:value-of select="/root/QueryString/searchenginename"/>.aspx?pagenum=<xsl:value-of select="/root/QueryString/pagenum"/></xsl:when>
                    <xsl:when test="/root/RunTime/PageType = 'category'"><xsl:value-of select="$site"/>c-<xsl:value-of select="/root/RunTime/PageID"/>-<xsl:value-of select="/root/QueryString/searchenginename"/>.aspx</xsl:when>
                    <xsl:when test="/root/RunTime/PageType = 'product'"><xsl:value-of select="$site"/>p-<xsl:value-of select="/root/RunTime/PageID"/>-<xsl:value-of select="/root/QueryString/searchenginename"/>.aspx</xsl:when>


I also thought this would be a more simple approach


                <xsl:template match="/">
                  <link rel="canonical">
                    <xsl:attribute name="href">
                      <xsl:value-of select="concat(/root/System/StoreUrl, /root/Runtime/PageName)"></xsl:value-of>


The above will return the following when on a product page

<link rel="canonical" href="http://localhost/pccom/store/p-16.aspx" />




asked May 16, 2017 in MultiStore by jhausotter (200 points)
I am a new user of both AspDotNetStorefront Version 10 (upgraded from 9.3) and Moz Pro. I also am fairly confused about how to use Canonical tags with ASPDNSF. Why isn't this built into the software? If I was to use the XMLPackage listed above, where in the system do I add a reference to is so that it will be pulled into every page on the site?

1 Answer

0 votes
Try pulling just "root/System/RequestedPage" This works for me in 9.5.1, should work in 10 I would think?
answered May 18, 2017 by jerm324 (175 points)