HowTo: Cms and Search Engine Rankings (using the document Path instead of the ID)
What you should know
Google and other search engines have quite a complicated system when ranking your page.
There are some tricks that help you getting a better rank by using corinis
Get rid of the id
The most important thing is to get rid of the ?Document_id=1345324 . Search engines do not like this. Corinis allows you to specify the whole path in the URL (quite like a wiki). To integrate this you have to change the WEB-INF/web.xml a little and change some xsl and jsp code.
the web.xml
Add this in your web.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> <web-app> <servlet> <servlet-name>corinis</servlet-name> <jsp-file>/index.jsp</jsp-file> </servlet> <servlet-mapping> <servlet-name>corinis</servlet-name> <url-pattern>/en/*</url-pattern> </servlet-mapping> </web-app>
This tells tomcat to call index.jsp when you enter an URL beginning with /en/.
the jsp code
After that you have to tell the Corinis CMS how you want your links. To do this call the function:
// for all used Cms classes
cms.setInternalLinkStyle("/en$path");
You have to do this for all CMS classes (Cms/CmsLifeFileManager).
Now corinis will automatically translate the path after /en to the correct document. Also all internal links (set with the cms) will atomatically be translated to the new pathstyle.
the xsl
The only thing missing are the navigtion xsls. Right now the are probably still using ?Document_id=. If you use CmsLifeFileManager?.getFileManagerComplete() this would be an example xsl that takes care of the path:
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:for-each select="/CMSFILEMANAGER/ENTRY"> <xsl:call-template name="ENTRY"> <xsl:with-param name="prevPath"></xsl:with-param> </xsl:call-template> </xsl:for-each> </xsl:template> <!-- The entries --> <xsl:template name="ENTRY"> <xsl:param name="prevPath"/> <!-- only folder --> <xsl:if test="./@type='0'"> <a href="/en/{$prevPath}{translate(NAME,' /&?#','_____')}/{NAME}"></a> <br/> <xsl:for-each select="ENTRY"> <xsl:call-template name="ENTRY"> <xsl:with-param name="prevPath"><xsl:value-of select="translate(../NAME, ' /&?#', '_____')"/>/</xsl:with-param> </xsl:call-template> </xsl:for-each> </xsl:if> </xsl:template> </xsl:stylesheet>
The translate makes sure special characters are correctly escaped (with an underscore), and passes the current path to the next level.
A typical index.xsl would look like this
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:for-each select="/CMSFILEMANAGER/ENTRY"> <xsl:if test="./@type = 1"> <div> <a class="teaserLink" href="{translate(NAME, ' /&#?', '_____')}"> <xsl:value-of select="CONTENT/header"/> </a> </div> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Now instead of Document_id=245235 you have /en/My_Folder/A_Page giving you a MUCH better ranking, since you actually named your pages
META tags
You should also describe your content with meta tags. There are two ways to do so:
meta directly in the template
If you do not have a jsp-border you can add the meta tags directly in the template.
<html> <head> <meta name="description"><corinis-attribute name="content"><corinis-field type="show" name="metadesc"/></corinis-attribute></meta> </head> <body> <corinis-comment>Meta description: <corinis-field type="edit" name="metadesc"/><br/></corinis-comment> </body> </html>
In this case you have to make sure not to use " in your text - otherwise this whole thing will not work.
meta with xsl
You can also reach inside a documents content by Cms.getEntry() combine this with a xsl and you can create wonderfull meta tags.
Sitemap
Apart from the additional usability your site gets, a sitemap also helps increasing your internal crosslinks thus pushing the pagerank a little more. Just use CmsLifeFileManager?.getFileManagerComplete() and a nice xsl to create a complete sitemap.
