I need to place unique description and keywords meta tags to each page. Tried this. But its not clicking.
@{
ViewBag.Title = "Title";
ViewBag.Description = "Test";
ViewBag.Keywords = "Test1, Test2, Test3";
}
How do I place the meta tags in MVC 3 Razor Engine?
You need to emit
<meta>
tags in your layout page that use the values.You can get the values in the tags by writing
@ViewBag.Description
.In the layout you could define a section:
and in view:
or in the layout:
and in the view:
You can do as you did, but you have to link them in your _Layout.cshtml. Add this to your _Layout.cshtml in the
<head>
section: