Have a #title processing instruction, so page title can be easily changed.

See also FeatureRequests/EditablePageTitle

GustavoNiemeyer would like to have some means to set page title. Quoting his mail:

The site I mention uses moin more like a CMS than a public wiki, and that made me miss a small feature. I'd like, for instance, to create a url labix.org/smart, and have the page title being "Smart Package Manager", rather than just "smart" (and I don't want labix.org/SmartPackageManager either, in that specific case). So I'd like to be able to say: well, for that page, please use the given title. Nir suggested using #pragma title for that, and hacking the theme. While this would work for the title shown on the current page, the browser title bar and any links to that page (trail, etc) will still point to the stripped name.

So, that's what the attached patch implements. While I understand that for a general wiki it's not useful, since page naming should really be CamelCase, I don't think it would hurt to have the feature available for those who want to use moin as a CMS, like I do for that site.

As a side note, given the usage and current implementation, I believe that the split_title() function name is a bit misleading. I would suggest something like get_title() for it.

What do you think about the feature?

Patch updated somewhat often and working demo available at http://labix.org/snippets/moin-title

another hack seen there

#title Smart Package Manager
#pragma hide-title true
attachment:smartpm.png

Current Version of the labix.org Patch

The patch available at http://labix.org/snippets/moin-title currently is for MoinMoin 1.6.1. Here is an updated version of this patch for MoinMoin 1.8:

--- MoinMoin/Page.py    2008-08-31 22:00:00.000000000 +0200
+++ MoinMoin/Page.py
@@ -715,6 +715,10 @@
         @return: pagename of this page, splitted into space separated words
         """
         request = self.request
+
+        if self.pi.get("title"):
+            return self.pi["title"]
+
         if not force and not request.user.wikiname_add_spaces:
             return self.page_name
 
@@ -953,6 +957,9 @@
                 else:
                     request.setPragma(key, val)
 
+            elif verb == "title":
+                pi["title"] = args
+
         pi['acl'] = security.AccessControlList(request.cfg, acl)
         return pi

Discussion

It may confuse people when you link to the page foo as Foo Bar Baz. What if you already have a Foo Bar Baz page? where does this link point to? However, having a custom page name - not only the title, can be very important to international wikis, when they would like to have plain ASCII page names that can be pasted anywhere on the net, and any Unicode page name. In this case, you want to hide the real name when you link in the wiki.

Using the modified page title can be done in the same way proposed here, by using the = heading level 1 = of the page instead of using a processing instruction or a pragma. See FeatureRequests/EditablePageTitle. -- NirSoffer 2005-10-26 15:31:42

I'm not sure I understand what you mean. The page title is used in many other places besides a heading in the page. A header in the page won't even look like a title depending on the theme. -- Gustavo Niemeyer

#pragma title can affect the html title if you override ThemeBase's html_head in your theme, so you can do everything in the theme. You probably can't affect the page trail if you don't change core code, but it strikes me that you'd want to do such a thing. If the page name is ga2006/agenda and the title is "Agenda of the 2006 general assembly", I'd still like ga2006/agenda to show on the page trail. -- Antonis Christofides

Detailed page titles are very important from a search engine optimisation point of view. It is the title that appears in search engine results pages and often improving your page title can shoot the page to the top of the results. Also related to this are the meta tags, description and keywords in the head of the document. The description plays an important role in the ranking of pages and is used in the results pages.

The link above to http://labix.org/snippets/moin-title does have an altered title but after looking at the source I can not see the "additional #title instruction that if inserted at the top of a page will change the title for the given page."

What would be ideal is an additional field above the editing area where the title for each page can be specified and also a small text area to specify a description (not nearly as important). These measures would help make the wiki far more visible in search engines and therefore increase web traffic. Please help. I am not a programmer and am not understanding how this can be acheived. :D -- Sarah 2007-01-02 11:36:23

While dealing with Googles Webmaster Tool I see that an appropriate title for each site will affect the site ranking massive. Furthermore a declaration of the description tag is needed for a more informative representation of the page within Googles listings. I think these "SEO" features would be more than helpful. :D Claus Gaisser 2015.01.16 9:30

MoinMoin: FeatureRequests/CustomPageTitle (last edited 2015-01-16 16:06:40 by p5486717A)