Tuesday, November 14, 2023

SEO is simplified in Blazor .Net Core 8

SEO is simplified in Blazor .Net Core 8.  Simply put whatever HTML you may want to use in HeadContent Tag.  Dynamic parameters can be added as shown below.


 @page "/"

<HeadContent>
    <PageTitle>@title</PageTitle>
    <meta name="description" content="@description">
        <meta name="keywords" content="@keywords" />
        <meta name="author" content="@author" />

        <meta property="og:type" content="article" />
        <meta property="og:title" content="something_og:title" />
        <meta property="og:description" content="something_og:description" />
        <meta property="og:url" content="something_og:url" />
        <meta property="og:site_name" content="something_og:site_name" />
        <meta property="og:locale" content="en_US" />

        <meta name="twitter:card" content="summary_large_image" />
        <meta name="twitter:title" content="something_twitter:title" />
        <meta name="twitter:description" content="something_twitter:description" />
        <meta name="twitter:creator" content="something_twitter:creator" />
        <meta name="twitter:domain" content="something_twitter:domain">
        <meta name="twitter:site" content="something_twitter:site">
</HeadContent>

<h1>Hello, world!</h1>

Welcome to your new app.

    @code {
        private string description = "Description set by component";
        private string title = "Title set by component";
        private string keywords = "keyword1, keyword2, keyword3";
        private string author = "author1";
    }
  

----

Output

-------




Most Recent Post

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape