{if !empty($canonical)}
    <link rel="canonical" href="{$config->root_url}{$canonical}">
{else if $smarty.server.REQUEST_URI|stristr:'?'}
    <link rel="canonical" href="{$config->root_url}/{$routes->full_path}">
{else if $smarty.server.REQUEST_URI|substr:'-1' == '/' && !empty($routes->first)}
    <link rel="canonical" href="{$config->root_url}/{$routes->full_path}">
{/if}
