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 asp.net 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:

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

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.