HtmlUrls

Summary: Add ".html" to the end of page urls
Version: 2006-09-03
Prerequisites: PmWiki 2.1.0
Status: Core
Maintainer: Pm
Categories:PageNaming
Discussion: HtmlUrls-Talk

Questions answered by this recipe

  • Can PmWiki urls end with .html?

Description

Many PmWiki sites are configured so that urls are shorter and look like they go directly to individual pages (e.g., CleanUrls). Adding the following settings to local/config.php causes PmWiki to add a .html extension to the end of page urls.

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

Notes

First, if you're considering adding .html extensions to your urls, we recommend that you not do it. Even the W3C recommends against it [1]:

So what should I do? Designing URIs / What 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.

Still, if you (or your client) really wants to see that ".html" at the end of the urls, then the above recipe lets you do it. All it does is add ".html" to any page urls that PmWiki encounters during page and template processing.

The above recipe has been enabled on this page, and you can see that all of the links to other pages have the ".html" extension added to them.

See Also

Contributors

Comments

See Discussion at HtmlUrls-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.