Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Razor Engine - SEO Meta tags

Tags:

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?

like image 863
Aseem Gautam Avatar asked Apr 03 '11 17:04

Aseem Gautam


People also ask

Do search engines still use meta tags?

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.”

What are meta tags for SEO?

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.

Does meta tags affect SEO?

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.

Does Yoast add meta tags?

The Yoast SEO plugin makes it very easy to add Facebook's Open Graph meta tags. This feature is enabled by default.


1 Answers

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";
}
like image 167
Darin Dimitrov Avatar answered Nov 09 '22 23:11

Darin Dimitrov