Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Render MetaDescription as a meta tag to layout file

Vote:
 

So I want to send my property :

[Display(
GroupName = Global.GroupNames.MetaData,
Order = 100)]
[CultureSpecific]
[UIHint(UIHint.Textarea)]
public virtual string MetaDescription { get; set; }

to my view as a meta tag.. any idea on how to do this? 

I'm a bit confused about this...

#79083
Dec 09, 2013 12:25
Vote:
 

A common way is to add the MetaDescription to a super class of your page type class.

For example 

public abstract class SitePageBase : PageData
{
  [Display(
  GroupName = Global.GroupNames.MetaData,
  Order = 100)]
  [CultureSpecific]
  [UIHint(UIHint.Textarea)]
  public virtual string MetaDescription { get; set; }
}

And in your layout where you have the <head> area, you simply write

<meta name="description" content="@Model.CurrentPage.MetaDescription" />

Or if your model accually is the Page you'll write @Model.MetaDescription

 

#79088
Edited, Dec 09, 2013 12:46
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.