Developer forum

Forum » CMS - Standard features » RE: Meta title page in RAZOR

RE: Meta title page in RAZOR

Ricardo Pereira
Reply

Hi,

How can i change the meta title page in RAZOR?

 

 


Replies

 
Jan Sangill
Reply

Hi,

Are you refering to updating item types or refering to something else?

http://developer.dynamicweb.com/documentation/for-developers/item-based-structure/querying-items.aspx

Or are you just refering to the template file, where you display the meta title?

 

 
Nicolai Høeg Pedersen
Reply

Like this?

<title>

@WhateverRazorCode

</title>

 
Morten Bengtson
Reply

Nicolais example didn't work for me. DW overrides the title.

But this works...

You can extend the title if you include @GetValue("Title")...

<title>@GetValue("Title") - some text here</title>

Or you can replace the title by setting the tag value...

@{ this.Model.Template.SetTag("Title", "my custom title"); }
<title></title>

 

 
Nicolai Høeg Pedersen
Reply

Ah, yes. Forgot that - thank you Morten!

Parsing of the header can also be disabled by adding disableparsing:true to the head tag:

<head data-settings="disableparsing:true">
 
Morten Bengtson
Reply

I tried with disableparsing:true, but it seems like it has no effect on the title element. It works for other meta tags though :)

 
Mikkel Ricky
Reply

Another way to do this is by putting @GetValue("Title") (which Dynamicweb looks for and adds if not found) inside a Razor comment:

<title>@GetValue("Item.Name")@*@GetValue("Title")*@</title>

Best regards,
Mikkel

 
Morten Bengtson
Reply

Great solution, Mikkel.

Although, I think the next developer will be scratching his head and wondering what happened when he finds something like that in a template :D

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Well, MIkkel's solution works, but you are right. Next developer will have o figure it out :)

 

You must be logged in to post in the forum