--- nodewords/nodewords_basic/includes/nodewords_basic.nodewords.tags.inc.old	2010-03-23 05:22:49.000000000 +0700
+++ nodewords/nodewords_basic/includes/nodewords_basic.nodewords.tags.inc	2010-03-23 05:22:16.000000000 +0700
@@ -69,6 +69,43 @@ function nodewords_basic_canonical_form_
  */
 function nodewords_basic_canonical_prepare(&$tags, $content, $options) {
   if (!empty($content['value'])) {
+    $content['value'] = trim($content['value'], '/');
+  }
+
+  if (empty($content['value'])) {
+    $path = '';
+
+    switch ($options['type']) {
+      case NODEWORDS_TYPE_FRONTPAGE:
+        $content['value'] = '<front>';
+        break;
+
+      case NODEWORDS_TYPE_NODE:
+        $path = 'node/' . $options['id'];
+        break;
+
+      case NODEWORDS_TYPE_PAGE:
+        $path = $_GET['q'];
+        break;
+
+      case NODEWORDS_TYPE_TERM:
+        $path = 'taxonomy/term/' . $options['id'];
+        break;
+
+      case NODEWORDS_TYPE_USER:
+        $path = 'user/' . $options['id'];
+        break;
+    }
+
+    if ($path) {
+      $content['value'] = drupal_get_path_alias($path);
+    }
+  }
+  elseif (!empty($content['value']) && strpos($content['value'], '/') === 0) {
+    $content['value'] = drupal_substr($content['value'], 1);
+  }
+
+  if (!empty($content['value'])) {
     $tags['canonical'] = check_url(
       nodewords_url(
         trim(nodewords_replace_tokens($content['value'], $options), '/'), $options
