NoCarrier
NoCarrier

Reputation: 2588

OrchardCMS, how to set HTML title tag to page title

How does one dynamically set the HTML title tag on a page in Orchard?

I have a custom theme, and out of the box Orchard sets only the sitename as the page title.

looking in the Document shape, i see this

<title>@Html.Title(title, siteName)</title> 

So for example, if my site is called "MySite" and my page is called "MyPage", the title should be

<title>MySite - MyPage</title>

There is another question that seems to deal with a similar issue, though it references a Title Override module as the answer. This module no longer works with newer/current versions of Orchard.

Alternatively, I've considered just using javascript to set the title, but a) I don't know how to get a handle on the page title and b) I don't know which shape in which I would do this

thanks in advance

Upvotes: 2

Views: 862

Answers (1)

Bertrand Le Roy
Bertrand Le Roy

Reputation: 17814

@Html.Title is just a helper, for which you can find the source code here: https://github.com/OrchardCMS/Orchard/blob/6720b71cf3474a9a7b8a8cc9a99d58b1e733acfa/src/Orchard/Mvc/Html/LayoutExtensions.cs

As you can see, it takes a variable number of parameters. If you omit the site name in your call, it won't get output.

<title>@Html.Title(title)</title>

Note that you could also simply do <title>@title</title>.

Upvotes: 4

Related Questions