One of the things which is pleasing about having (finally) built the fiennes.org site and running HEAD of InForm is that it gives me the chance to really tweak and optimise things on a live site without needing to co-ordinate things with anyone other than myself. While browsing Google Webmaster, I noticed that it was complaining that I had 79 Duplicate title tags which I found somewhat surprising. On closer inspection it appeared that this was because the title that is generated when you ask to see a zoomed version of an embedded image is the same as the default title for a page. Therefore if you have a page with 6 zoomable images then Google will see 7 pages with the same title.
Unfortunately this has a few hoops to jump through. The <title> tag is rendered in the <head> of a page, but the view that is responsible for carrying out the actions and outputting the results is in the <body> which follows on from the <head>. Therefore if we need our <title> to be customisable by the view being invoked then we have to look at the ordering of when which element gets invoked.
As it happens, InForm rendering works by traversing down the pages in an incoming request and asking each view for each level (read views for parent pages, and whatever the target view is for the destination page) to decide whether or not the request is valid and if it is then to define which templates should be utilised when the templates are finally rendered. The original motivation behind this was to make it so that any element in the system was hot swappable, but it also has the advantage that we can alter our rendering pass to the following sequence of events:
The end result of this is that we now have the architecture to let the view templates to customise any part of the page rendering, not just the template tree inside the <body>.
I have implemented an extension to the default title rendering engine so that you can either declare $title_explicit which replaces the entire of the default title, or $title_extra which includes the value in addition to the default template. The rendering algorithm for the zoomed image utilises this to set up $title_extra which includes either the title of the zoomed image into the <title>, or if this is not defined then a title that includes the id of the image.
If you zoom in the images to either side of this paragraph and look at the page title then you will see that it now includes the appropriate information to distinguish it from the default page view. Once google re-indexes the pages then we should see the warnings disappear from webmaster, and hopefully better page performance as a result.
We will need to sweep through all the publicly accessible views in the InForm hierarchy working out which other ones are being picked up by google and therefore are a priority for altering the <title> tags, but webmaster will help us identify the most likely candidates.