Use widget at HTML head

Topics: Customizing Orchard
Jan 28, 2013 at 9:08 AM

I'd like to include styles and scripts in the html head of the website using HTML widget (say, one at global layer, one for blog pages, one for certain page). Is it possible to modify theme and add a new zone to the HTML head tag?

Jan 28, 2013 at 11:31 AM

Found an answer here: https://orchard.codeplex.com/discussions/258122

mistercain wrote:

Here's what I did, seems to work well but Bertrand let me know if this is wrong...

1. In Theme.txt add a Zone called Head
2. Bring in the Document.cshtml from TheThemeMachine and add @Display(Model.Head) in the <head> tag somewhere.  I put it just above the </head>
3. In the Views folder add a Shape Template called Widget-Head.cshtml with the following code:

@{
    Model.Metadata.Wrappers.Clear();
}
@Display(Model.Content)

Now you can add an HTML widget to the Head zone containing your markup of choice and it will be unencumbered by the default article tags.

I hope this helps!

This works