This project is read-only.

@Html.Title() is blank

Topics: Troubleshooting, Writing themes
Jul 19, 2011 at 3:36 PM


Developing using source in VS 2010.


When I test via http://localhost/ the <title> tag in HTML is blank so all that is displayed in browser window is:


localhost without the page title which should be "Site name" +  page name. Does Base url have any bearing on this?

Jul 19, 2011 at 11:19 PM

What theme are you using? Can you describe the exact steps to repro? (cause I can't seem to be able to).

Jul 20, 2011 at 12:04 AM

A new child theme of Theme Machine - here's my manifest

Name: ITF Taekwon-do World Cup 2012
Author: Phuture Design
Description: Theme for the ITF Taekwon-do World Cup 2012 in Brighton, England
Version: 1.0
BaseTheme: TheThemeMachine
Zones: Header, Navigation, Featured, AsideFirst, Content, AfterMain, Footer

I have used the Document.cshtml from SafeMode theme as I want to embed some scripts in the <head> - I have linked the scripts from Layout.cshtml but need to initialise them in Document.cshtml. The page title call is untouched


<meta charset="utf-8" />    


Jul 20, 2011 at 12:22 AM

No clue what's happening here. Can you try to switch back the the theme machine just for the purpose of checking if it still reproduces? Can you also try to output Layout.Title?

Jul 20, 2011 at 12:39 AM

Switching back to theme machine fixes it

@Layout.Title does display on new theme as well - it must be the Document.cshtml override


Can I inject this JS into the Layout.chtml instead of in Document to go in <head> - the only way seems to be Script.Include("jquery.generic.js").AtHead();

but I need to insert a block of code like below


 <!-- intialise JQuery functions -->   


$(function () {            var WorldCupStart = new Date();           

WorldCupStart = new Date(WorldCupStart.getFullYear() + 1, 11 - 1, 04);           

$('#defaultCountdown').countdown({ until: WorldCupStart });           

$('#year').text(WorldCupStart.getFullYear());        });

Jul 20, 2011 at 1:01 AM


Page title fixed with: (

    if (MvcHtmlString.IsNullOrEmpty(Html.Title()))    {    string title = Model.Title;    string siteName = WorkContext.CurrentSite.SiteName;    Html.AddTitleParts(siteName, title);

Layout.cshtml fixed with:

//  intialise JQuery functions in the Foot   

using (Script.Foot())    {   



Jul 20, 2011 at 1:05 AM

You were faster than me. The using is indeed the correct way of doing this. One should not put script directly into document.cshtml.

Jul 20, 2011 at 1:45 AM

great - thanks  - be in touch soon no doubt. Orchard is great - been after an OS .NET CMS for a long time