[pmwiki-users] Adding .html . . .

Patrick R. Michaud pmichaud at pobox.com
Sun Sep 3 22:42:23 CDT 2006


On 9/3/06, Ben Wilson <dausha at gmail.com> wrote:
> The new group
> said that Google could not handle dynamic content and only played well
> with URLs ending in .html. As you read this, I'm sure many of you
> chuckle becuase that's patently absurd. 

Not only is it absurd, but having ".html" in a url goes completely 
against the W3C's own recommendations.  In "Cool URIs don't 
change" [1], the "What to leave out" section says to leave out

    File name extension. This is a very common one. "cgi", even 
    ".html" is something which will change. You may not be using HTML 
    for that page in 20 years time, but you might want today's 
    links to it to still be valid. The canonical way of making 
    links to the W3C site doesn't use the extension.

None of W3C's links that I have seen have the .html, and I guarantee 
*they're* indexed by Google.  :-)  

And, of course, "directory urls" don't end in .html, but they're
indexed.  And, of course, Apache has a lot of "content negotiation" 
features built in to try to make it possible for urls to avoid 
hard-coded extensions.

> However, it got me to thinking that I would like to have the .html
> dangling from the end of my pages. If nothing else, just to show that
> it can be done easily in PmWiki should one desire it.

Indeed, as you discovered, PmWiki already supports it.  :-)

> $LinkPageSelfFmt = "<a class='selflink' href='\$LinkUrl.html'>\$LinkText</a>";
> $LinkPageExistsFmt = "<a class='wikilink' href='\$LinkUrl.html'>\$LinkText</a>";
> [...next message...]
> But, there's a problem. It does not play well with page actions.
> Anybody have a solution?

Of course!  In local/config.php:

    $EnablePathInfo = 1;
    $FmtP['!\\$ScriptUrl/[^?#\'"\\s<>/]+/[^?#\'"\\s<>]+!'] = '$0.html';
    $FmtPV['$PageUrl'] = 'PUE("$ScriptUrl/$group/$name.html")';

These lines cause all page targets to have .html added to the end
of the url.  (This even works for page templates.)  

Now added as a recipe and demonstrated at:

    http://www.pmwiki.org/wiki/Cookbook/HtmlUrls 

Pm

1. http://www.w3.org/Provider/Style/URI




More information about the pmwiki-users mailing list