Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • strawberrylatte 34 posts 103 karma points
    Apr 08, 2021 @ 07:31
    strawberrylatte
    0

    other option to get page title

    Hello, I am using Model.Name to get the page title of the page, but for Home page I would like to name the page title as the name of the website instead. Can someone point me to the right direction?

    <title>@Model.Name</title>
    
  • strawberrylatte 34 posts 103 karma points
    Apr 08, 2021 @ 07:49
    strawberrylatte
    0

    Answering my own question,

    @{
        var applicationName = "Your Website Name";
    }
    @if (Model.HasValue("metaTitle"))
    {
        <title>@Model.Value("metaTitle")</title>
    }
    else
    {
        if (Model.Id == Umbraco.ContentAtRoot().FirstOrDefault().Id)
        {
            <title>@applicationName</title>
        }
        else
        {
            <title>@Model.Name | @applicationName</title>
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft