Use the razor engine to do an SEO Helper

Source: Internet
Author: User

The items at hand need to be SEO optimized, just consider doing an SEO Helper, using the MVC Razor view engine, which is really easy and enjoyable:

1, first of all, in the Layout page render a section, called SEO, as follows:

<head> <title> @ViewBag .title</title> @RenderSection ("SEO", false) ...

2. Add a seo.cshtml to the App_Code code as follows:

@helper metatag (String description,string keywords) {<meta name= "description" content= "@description"/> Name= "KEYWORDS" content= "@keywords"/>} @helper NoIndex () {<meta name= "robots" content= "NoIndex"/>}

3, in the implementation page, the definition of SEO section

@section SEO {@SEO. MetaTag ("This is a description to my site.", "This keyword,serperated by Comma,another,keyword")}

When you browse the page, you can find <meta name= "description" content= ... "/> and <meta name=" keyword "content=" ... "> has been added to the page.

Of course, if you do not want the search engine included in the page, you can already use the @SEO. NoIndex () written as a not allowed to be included in the <meta>

Related Article

Beyond APAC's No.1 Cloud

19.6% IaaS Market Share in Asia Pacific - Gartner IT Service report, 2018

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.