Razor Engine - SEO Meta tags

前端 未结 3 1681
名媛妹妹
名媛妹妹 2020-12-24 14:01

I need to place unique description and keywords meta tags to each page. Tried this. But its not clicking.

@{
    ViewBag.Title = \"Title\";
    ViewBag.Descr         


        
3条回答
  •  心在旅途
    2020-12-24 14:26

    In the layout you could define a section:

    
        ...
        @RenderSection("metas")
    
    

    and in view:

    @section metas
    {
        
        
        
        ...
    }
    

    or in the layout:

    
        
        
        
        ...
    
    

    and in the view:

    @{
        ViewBag.Title = "Title";
        ViewBag.Description = "Test";
        ViewBag.Keywords = "Test1, Test2, Test3";
    }
    

提交回复
热议问题