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?
No. “Our web search (the well-known search at Google.com that hundreds of millions of people use each day) disregards keyword metatags completely. They simply don't have any effect in our search ranking at present.”
Meta tags are snippets of code that tell search engines important information about your web page, such as how they should display it in search results. They also tell web browsers how to display it to visitors. Every web page has meta tags, but they're only visible in the HTML code.
Social meta tags do not directly affect search engine rankings, but they do make your site preview look better on social media, like which thumbnail image and description text they use, so they are worth creating.
The Yoast SEO plugin makes it very easy to add Facebook's Open Graph meta tags. This feature is enabled by default.
In the layout you could define a section:
<head>
...
@RenderSection("metas")
</head>
and in view:
@section metas
{
<meta name="description" content="Test" />
<meta name="title" content="Title" />
<meta name="keywords" content="Test1, Test2, Test3" />
...
}
or in the layout:
<head>
<meta name="description" content="@ViewBag.Description" />
<meta name="title" content="@ViewBag.Title" />
<meta name="keywords" content="@ViewBag.Keywords" />
...
</head>
and in the view:
@{
ViewBag.Title = "Title";
ViewBag.Description = "Test";
ViewBag.Keywords = "Test1, Test2, Test3";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With