Recommended Way to inject META tags depending on the page you are

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 12 ans
By default I have some Social tags as follow:

   <meta property="og:title" content="mysite" />
   <meta property="og:url" content="http://www.mysite.com/" />
   <meta property="og:image" content="http://www.mysite.com/social.png" />

But when I am inside a specific "wine" page I would like to change some of the values to

   <meta property="og:title" content="My Title" />
   <meta property="og:url" content="http://www.mysite.com/wine/aglianico-pandiani" />
   <meta property="og:image" content="http://www.mysite.com/content/images/thumbs/0000111_aglianico_2010_pandiani_300.png" />

=========================
So I need something that works like the Title of the page where it displays either the value that comes from
the view itself (when the path contains "\wine\") or displays the default values.

What's the recommended way to achieve this using NOP ?

Thanks in advanced,
Fil
Il y a 12 ans
haha
...I just found a quick way.

I simply write on the Root.cshtml the following:

    @if (@Request.Url.AbsoluteUri.Contains("/wine/"))
    {
        <meta property="og:title" content="@Model.Name - mysite" />
        <meta property="og:url" content="@Request.Url.AbsoluteUri" />
        <meta property="og:image" content="@Model.DefaultPictureModel.ImageUrl" />
    }
    else
    {
        <meta property="og:title" content="My Title" />
        <meta property="og:url" content="http://www.mysite.com/" />
        <meta property="og:image" content="http://www.mysite.com/social.png" />
    }


and "pretend" to have the right MODEL with the right values at runtime.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.