Reputation: 457
I have a number of pages within my site that I do not want the <h1>
page title to be displayed on (e.g. home page or pages that use a slide as a page title).
I can hide the title shape easily using placement: <Place Parts_Title="-"/>
, but the knock-on effect of this is that it prevents the meta title being added to the head
section of the page.
Can anyone tell me how to hide the title displayed on the page but retain the meta title, without completely removing the <h1>
from the Parts.Title
shape?
I have tried targeting the h1
in CSS, but not all content items have selectors that I can narrow it down to.
Any help much appreciated.
Upvotes: 0
Views: 464
Reputation: 730
Your should change Title Part Shape (Like @Szymon Seliga suggests)
But for targeting only specific content you could use placement.info something like that:
<Match Path="~/">
<Place Parts_Title="Header:1;Shape=Parts_Title_OnlyMeta"/>
</Match>
<Match ContentType="NameOfContentType">
<Place Parts_Title="Header:1;Shape=Parts_Title_OnlyMeta"/>
</Match>
Also you need to create alternate like that ~/Views/Parts/Title.OnlyMeta.cshtml
Upvotes: 1
Reputation: 820
Override the TitlePart's shape template, either using the shape tracing tool or by adding a shape template file (Title.cshtml
or Title.Parts.cshtml
) to your themes Views
folder.
The default template is:
@{
Layout.Title = Model.Title;
}
<h1> @Model.Title </h1>
So your new template can have the same code, except for the line with the h1
tag :)
If you want to render different title shape templates for different content types, use Alternates ie. Title.Parts-MyContentType.cshtml
is a title shape template only for MyContentType
content type.
Upvotes: 4