This project is read-only.

Customizing Title Tag in Pages

Topics: Customizing Orchard
Feb 23, 2011 at 8:05 PM

How does one override the title tag in page content types? The current algorithm of using the page title plus a custom separator plus the name of the website is not good enough for my client.

I created a custom part for the page type that allowed them to specify a MetaTitle, MetaKeywords, and MetaDescription, where MetaTitle is to be placed in the page's title tag when specified. Keywords and Description are easy because their meta tags, but trying to inject a value in the title tag is difficult because I couldn't find a SetTitle or equivalent on IResourceManager and IPageTitleBuilder appears to be for the admin (I think).

I saw the Document Shape, various Layout Extensions that use IPageTitleBuilder, etc., but I can't seem to bring all this information together coherently to solve this challenge.

Any help would be much appreciated.



Feb 23, 2011 at 10:44 PM

Did you try to set Layout.Title?

Feb 24, 2011 at 4:48 PM

I did try to set Layout.Title = part.MetaTitle in the driver.

What's interesting about that is that if you allow the driver to display for other display types besides "Detail", you will see the MetaTitle show up in the title tags for admin pages followed by " - " and the site name.

However, on the Detail display type, which is where I want the actual title tag to be changed, it just keeps displaying the page title followed by " - " and the site name. I don't know if it is getting overwritten or just not working.



Feb 24, 2011 at 7:41 PM

Probably getting overwritten. It would be interesting to set a few breakpoints and see what happens. There has to be a better event to handle for that.

Mar 31, 2011 at 9:54 PM

@david.  See  That's what prevents IPageTitleBuilder from functioning correctly.