Hi this post is being, how to add meta tag in different pages in MVC.
We all know MVC has a one base master page, _layout and we need to add different meta tags for different pages, so if we add the meta description or any meta tags then it will applicable for all the inner and respective pages. So we must applied some changes which we can apply the meta tags different to every page, so time we could have different languages like Arabic, Spanish etc.
For this we need to create a different section and need to render it into the page like
Please subscribe for our future posts.
We all know MVC has a one base master page, _layout and we need to add different meta tags for different pages, so if we add the meta description or any meta tags then it will applicable for all the inner and respective pages. So we must applied some changes which we can apply the meta tags different to every page, so time we could have different languages like Arabic, Spanish etc.
For this we need to create a different section and need to render it into the page like
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
@RenderSection("metatags", false)
<title>My ASP.NET Application</title>
</head>
<body>
@RenderBody()
</body>
</html>
this @RenderSection placed in the master page and we need to push the scripts from the iner pages like
@section metatags
{
<meta name="test" content="test"/>
<meta name="test2" content="test"/>
}
<div>Page content</div>
Result:
<html>
<head>
<meta charset="utf-8">
<meta name="test" content="test">
<meta name="test2" content="test">
<title>My ASP.NET Application</title>
</head>
<body>
<div>Page content</div>
</body>
</html>
Thanks for visiting.Please support us by shearing our posts and like your social pages.Please subscribe for our future posts.
No comments:
Post a Comment