Summary: How to remove question mark beside links for non-existent pages
Categories: Links


How do I get rid of that blasted question mark beside links for non-existent pages?


Site-Wide Removal

If you simply want to remove the question mark but you want the link to continue to point to the edit-page, then add the following to your local/config.php:

  $LinkPageCreateFmt =
   "<a class='createlinktext' href='\$PageUrl?action=edit'>\$LinkText</a>";

If you want links to non-existent pages to link to the page, but without the edit action, then add the following to your local/config.php:

  $LinkPageCreateFmt = "<a class='createlinktext' href='\$PageUrl'>\$LinkText</a>";

If you want links to non-existent pages to not render as links at all, then use the following in local/config.php:

    $LinkPageCreateFmt = '$LinkText';

Group-Wide Removal

If you want all links to non-existent pages in specific groups, even when linked to outside of these groups, to continue to link to the non-existent page, and to not link to the edit-page, you will have to patch your pmwiki.php.

Add $LinkPageGroupEdit to the globals in the LinkPage() function:

  global $QueryFragPattern,$LinkPageExistsFmt,$LinkPageSelfFmt,

And change the following line in the LinkPage() function from:

   if (!PageExists($tgtname) && !preg_match('/[&?]action=/', $qf)) 


   $cr = ! PageExists($tgtname);
    if ($cr) {
      $grp = FmtPageName("\$Group", $tgtname);
      if (isset($LinkPageGroupEdit[$grp]))
        $cr = $LinkPageGroupEdit[$grp];
    if (! $cr)
      $fmt = ($tgtname==$pagename && $qf=='') ?  $LinkPageSelfFmt 
        : $LinkPageExistsFmt;
    elseif (!preg_match('/[&?]action=/', $qf)) 

When pmwiki.php is patched, then you can assign the groups for which you want edit-page linking to be disabled in your local/config.php. Simply add the group to the $LinkPageGroupEdit[] array and set the value to FALSE.

  i.e.  $LinkPageGroupEdit["Category"] = FALSE;

It is not uncommon for the Category group to have many non-existent pages linked to it. You may want to treat them as if they do exist since they will be linked to and probably display some content due to a pagelist directive in the GroupHeader or GroupFooter.

This type of modification can also be very useful for other groups besides the Category group. If your site has special groups which make use of the GroupHeader or the GroupFooter to provide the entire contents a of page, then you will have a group with almost all non-existent pages for which you may wish to apply this recipe. This technique allows an entire group of pages to be replicated with a different look, or with more or less data than the pages in the original group.

Specific Instance Removal:

Define a style and include it in your local/config.php:

  $HTMLStylesFmt['omit-quest'] = ' .omit-quest a.createlink { display:none; } '; 

Then use %omit-quest% before the specific link you wish to unadorn.

Note: In this case, the omit-quest only removes the question mark, the edit-page link is retained.

Additional Notes:

If you are using mostly empty groups such as described in the Group-Wide section, you may also be interested in modifying your Site.PageNotFound to eliminate warning messages for this group.


  (:if ! group special_group :)
     Normal PAgeNotFound Contents

Or, you could allow a Group.PageNotFound, in local/config.php add:

  $DefaultPageTextFmt = '(:include {$Group}.PageNotFound {$SiteGroup}.PageNotFound:)'; 

This uses PageNotFound in the current group if it exists, otherwise it uses Site.PageNotFound.

See Also



See discussion at RemoveQuestionMark-Talk