Building Title from Group Path
This short tutorial will provide a quick way for you to implement titles on your templates that reflect the names of the group and product. Generally speaking the most specific information should appear at the beginning of the title and then move towards least specific. There are two common mistakes that people make when constructing page titles
When customers bookmark the page the title doesn't have any specific information visible to them instead they just see the same store name over and over again for all their bookmarks. Below is a snippet of code that is good for group pages:
#set($title = "") #set($trailGroups = $formatHelper.reverse($breadcrumbHelper.getBreadcrumbTrail($group))) #foreach ($trailGroup in $trailGroups) #if ($velocityCount > 1) #set($title = "$title : ") #end #set($title = "${title}${trailGroup.getTitle()}") #end <title>$title</title> |
Let's walk through the logic of this code snippet for the group title tag:
$breadcrumbHelper.getBreadcrumbTrail($group))
]$formatHelper.reverse(...)
] and assign this to the variable $trailGroupsOn the item page we want similar logic, but want the item description to be in the beginning of the title tag.
#set($title = "$item.getDescription()") #set($trailGroups = $formatHelper.reverse($breadcrumbHelper.getBreadcrumbTrail($group))) #foreach ($trailGroup in $trailGroups) #set($title = "$title : $trailGroup.getTitle()") #end <title>$title</title> |
Let's walk through the logic of this code snippet for the item title tag:
$breadcrumbHelper.getBreadcrumbTrail($group))
]$formatHelper.reverse(...)
] and assign this to the variable $trailGroupsYou can also use the extended description to build up your meta description tag.
<meta name="description" content="${formatHelper.removeNewLines($formatHelper.removeHtml($item.getDescription()))}"/> |