diff -r 8a0834803bd3 0.11/hierwiki/formatter.py
--- a/0.11/hierwiki/formatter.py	Tue Nov 09 17:24:27 2010 +0100
+++ b/0.11/hierwiki/formatter.py	Fri Nov 26 15:40:29 2010 +0100
@@ -29,7 +29,8 @@
 
     # IWikiSyntaxProvider methods
     def get_wiki_syntax(self):
-        self.log.debug('HierWikiPlugin: Adding syntax')
+        self.log.debug('HierWikiPlugin: Adding syntax, pages_re=%s',
+                       self.pages_re)
         yield self.pages_re, self._format_syntax
         
     def get_link_resolvers(self):
@@ -88,21 +89,30 @@
         
     def _format_syntax(self, formatter, ns, match):
         page = match.group('relwiki')
-        return html.A(escape(page), href=formatter.href.wiki(self.pagebase.rstrip('/'),page), class_='wiki')
+        return html.A(escape(page),
+                      href=formatter.href.wiki(self.pagebase, page),
+                      class_='wiki')
 
     # More cache junk
     def _all_pages(self):
         self.pages = set(WikiSystem(self.env).get_pages())
         
     def _update(self, pagename):
-        self.log.debug('HierWikiPlugin: Running an update')
-        pagebase = '/'.join(pagename.split('/')[:-1])
-        if pagebase != '':
-            pagebase += '/'
+        # pagename is guaranteed to never be empty
+        self.log.debug('HierWikiPlugin: Running an update: pagename=%r',
+                       pagename)
+        # always-unmatching fallback pattern if no relative subpages exist for
+        # pagename
+        pattern = r'NEVERMATCHES^'
+        pagebase = '/'.join(pagename.split('/')[:-1]) or pagename
+        pagebase += '/' 
         if pagebase != self.pagebase or self.pagebase is None:
-            pages = set([p[len(pagebase):] for p in self.pages if p.startswith(pagebase)])
-            pattern = r'\b(?P<relwiki>' + '|'.join(pages) + r')\b'
-            self.log.debug('HierWikiPlugin: pagebase=%r pages=%r pattern=%r', pagebase, pages, pattern)
+            pages = set([p[len(pagebase):] for p in self.pages
+                        if p.startswith(pagebase)])
+            if pages:
+                pattern = r'\b(?P<relwiki>' + '|'.join(pages) + r')\b'
+            self.log.debug('HierWikiPlugin: pagebase=%r pattern=%r', pagebase,
+                           pattern)
             self.pages_re = pattern
             self.pagebase = pagebase
             WikiSystem(self.env)._compiled_rules = None
diff -r 8a0834803bd3 0.12/hierwiki/formatter.py
--- a/0.12/hierwiki/formatter.py	Tue Nov 09 17:24:27 2010 +0100
+++ b/0.12/hierwiki/formatter.py	Fri Nov 26 15:40:29 2010 +0100
@@ -29,7 +29,8 @@
 
     # IWikiSyntaxProvider methods
     def get_wiki_syntax(self):
-        self.log.debug('HierWikiPlugin: Adding syntax')
+        self.log.debug('HierWikiPlugin: Adding syntax, pages_re=%s',
+                       self.pages_re)
         yield self.pages_re, self._format_syntax
         
     def get_link_resolvers(self):
@@ -88,21 +89,30 @@
         
     def _format_syntax(self, formatter, ns, match):
         page = match.group('relwiki')
-        return html.A(escape(page), href=formatter.href.wiki(self.pagebase.rstrip('/'),page), class_='wiki')
+        return html.A(escape(page),
+                      href=formatter.href.wiki(self.pagebase, page),
+                      class_='wiki')
 
     # More cache junk
     def _all_pages(self):
         self.pages = set(WikiSystem(self.env).get_pages())
         
     def _update(self, pagename):
-        self.log.debug('HierWikiPlugin: Running an update')
-        pagebase = '/'.join(pagename.split('/')[:-1])
-        if pagebase != '':
-            pagebase += '/'
+        # pagename is guaranteed to never be empty
+        self.log.debug('HierWikiPlugin: Running an update: pagename=%r',
+                       pagename)
+        # always-unmatching fallback pattern if no relative subpages exist for
+        # pagename
+        pattern = r'NEVERMATCHES^'
+        pagebase = '/'.join(pagename.split('/')[:-1]) or pagename
+        pagebase += '/' 
         if pagebase != self.pagebase or self.pagebase is None:
-            pages = set([p[len(pagebase):] for p in self.pages if p.startswith(pagebase)])
-            pattern = r'\b(?P<relwiki>' + '|'.join(pages) + r')\b'
-            self.log.debug('HierWikiPlugin: pagebase=%r pages=%r pattern=%r', pagebase, pages, pattern)
+            pages = set([p[len(pagebase):] for p in self.pages
+                        if p.startswith(pagebase)])
+            if pages:
+                pattern = r'\b(?P<relwiki>' + '|'.join(pages) + r')\b'
+            self.log.debug('HierWikiPlugin: pagebase=%r pattern=%r', pagebase,
+                           pattern)
             self.pages_re = pattern
             self.pagebase = pagebase
             WikiSystem(self.env)._compiled_rules = None
