asp.net mvc - strategy for including SEO information such as meta keywords and descriptions

前端 未结 5 1214
礼貌的吻别
礼貌的吻别 2020-12-23 09:56

I was wondering what, if there is one, is the best practice for including SEO content such as meta descriptions and keywords in an ASP.NET MVC (I\'m using v3 RC) view. My in

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-23 10:56

    Add optional section to your layout page:

    
    
    
      @RenderSection("ExtraHeadContent", required: false)
    
    
    

    Now you can define meta tags on any content page using @section:

    @{
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    
    @section ExtraHeadContent {
        
    }
    
    
    The main content

    See Optional Razor Sections with Default Content by Marcin Doboz.

提交回复
热议问题