SeoTags


SeoTags create all SEO tags you need such as meta, link, twitter card (twitter:), open graph (og:), and JSON-LD schema (structred data)..

What is JSON-LD


Structured data is an advanced SEO topic that is a standardized format for providing information about a page and classifying the page content.
Google uses structured data to understand the content on the page. You can help us by providing specific information about your site, which can help your site display in richer features in search results.
Google search supports structured data in the three formats: JSON-LD (Recommended), Microdata and RDFa.
Google recommends using JSON-LD for structured data whenever possible.
If you are not familiar with Structred Data and JSON-LD read these linked pages.
Google has a gallery of examples and also here are the most popular examples of JSON-LD such as Article, Product, Organization, and etc...
There are some JSON-LD schema markup generators here and here which may help you to understand the format of JSON-LD.

JSON-LD (Referenced Example)


SeoTags now supports popular JSON-LD types such as Article, Product, Book, Organization, WebSite, WebPage, and etc...
This example shows JSOLD-LD in a referenced values usage.

Usage Code

Initialize your JSON-LD variables separately and reference them to each other by their Id.
You can reference a JSOLD-LD object using it's ReferTo() static method or just pass it's Id property.
For example for referencing an OrganizationInfo object to a WebSiteInfo.Publisher property you can one of these:

Then add it to SeoInfo.JsonLD object by calling appropriate Add() method for example (AddProduct, AddArticle, AddOrganization, etc...)

var organization = new OrganizationInfo
{
    Url = "https://site.com/",
    Name = "Organization Name",
    AlternateName = "Organization AlternateName",
    SocialMediaUrls = new[]
    {
        "https://twitter.com/MyTwitterId",
        "https://www.linkedin.com/company/MyCompanyId/"
    },
    Logo = new ImageInfo()
    {
        Url = "https://site.com/uploads/logo.jpg",
        Caption = "Image Caption",
        InLanguage = "en-US",
        Width = 400,
        Height = 400
    },
    ContactPoints = new[]
    {
        new ContactPointInfo()
        {
            Telephone = "+0123456789",
            ContactType = "sales",
            AvailableLanguage = new[] { "English" },
            AreaServed = new[] { "US" }
        },
        new ContactPointInfo()
        {
            Telephone = "+0123456789",
            ContactType = "customer service",
            AvailableLanguage = new[] { "English" },
            AreaServed = new[] { "US" }
        }
    }
};

var website = new WebSiteInfo
{
    Url = "https://site.com/",
    Name = "WebSite Name",
    AlternateName = "WebSite AlternateName",
    Description = "WebSite Description",
    InLanguage = "en-US",
    Publisher = organization.Id, //or OrganizationInfo.ReferTo(organization.Id) or OrganizationInfo.ReferTo(organization)
    SearchAction = new()
    {
        Target = "https://site.com/?s={search_term_string}",
        QueryInput = "required name=search_term_string"
    }
};

var breadcrumb = new BreadcrumbInfo
{
    Url = "https://site.com/posts/post-url",
    Items = new[]
    {
        ("https://site.com/", "Home"),
        ("https://site.com/posts/", "Post List"),
        ("https://site.com/posts/post-url", "Current Post"),
    }
};

var image = new ImageInfo()
{
    Url = "https://site.com/uploads/image-1.jpg",
    Caption = "Image Name",
    InLanguage = "en-US",
    Width = 1280,
    Height = 720
};

var author = new PersonInfo
{
    Url = "https://site.com/author",
    Name = "Author Name",
    Description = "Author Description",
    SocialMediaUrls = new[]
    {
        "https://twitter.com/AuthorId",
        "https://www.linkedin.com/company/AuthorId/"
    },
    Image = new()
    {
        Url = "https://site.com/uploads/author-image.jpg",
        Caption = "Author Name",
        InLanguage = "en-US",
        Width = 400,
        Height = 400
    }
};

var webpage = new SeoTags.PageInfo
{
    Url = "https://site.com/url/",
    Title = "Page Title",
    Description = "Page Description",
    Keywords = new[] { "SEO", "AspNetCore", "MVC", "RazorPages" },
    Images = new[] { ImageInfo.ReferTo(image) },
    DatePublished = DateTimeOffset.Now,
    DateModified = DateTimeOffset.Now,
    InLanguage = "en-US",
    Author = author.Id, //or PersonInfo.ReferTo(author.Id) or PersonInfo.ReferTo(author)
    WebSite = website.Id, //or WebSiteInfo.ReferTo(website.Id) or WebSiteInfo.ReferTo(website)
    Breadcrumb = breadcrumb.Id //or BreadcrumbInfo.ReferTo(breadcrumb.Id) or BreadcrumbInfo.ReferTo(breadcrumb)
};


Html.SetSeoInfo(seoInfo =>
{
    seoInfo.JsonLd.AddOrganization(organization);
    seoInfo.JsonLd.AddWebsite(website);
    seoInfo.JsonLd.AddBreadcrumb(breadcrumb);
    seoInfo.JsonLd.AddImage(image);
    seoInfo.JsonLd.AddPerson(author);
    seoInfo.JsonLd.AddPage(webpage);
});

Rendred Output

The following code shows the rendered output.

                <script type="application/ld+json">
{
    "@context": "https://schema.org",
    "@graph": [
        {
            "@type": "Organization",
            "@id": "https://site.com/#organization",
            "name": "Organization Name",
            "alternateName": "Organization AlternateName",
            "image": {
                "@id": "https://site.com/uploads/logo.jpg#image"
            },
            "sameAs": [
                "https://twitter.com/MyTwitterId",
                "https://www.linkedin.com/company/MyCompanyId/"
            ],
            "url": "https://site.com/",
            "contactPoint": [
                {
                    "@type": "ContactPoint",
                    "areaServed": "US",
                    "availableLanguage": "English",
                    "contactType": "sales",
                    "telephone": "+0123456789"
                },
                {
                    "@type": "ContactPoint",
                    "areaServed": "US",
                    "availableLanguage": "English",
                    "contactType": "customer service",
                    "telephone": "+0123456789"
                }
            ],
            "logo": {
                "@type": "ImageObject",
                "@id": "https://site.com/uploads/logo.jpg#image",
                "url": "https://site.com/uploads/logo.jpg",
                "inLanguage": "en-US",
                "contentUrl": "https://site.com/uploads/logo.jpg",
                "height": "400",
                "width": "400",
                "caption": "Image Caption"
            }
        },
        {
            "@type": "WebSite",
            "@id": "https://site.com/#website",
            "name": "WebSite Name",
            "description": "WebSite Description",
            "alternateName": "WebSite AlternateName",
            "potentialAction": {
                "@type": "SearchAction",
                "target": "https://site.com/?s={search_term_string}",
                "query-input": "required name=search_term_string"
            },
            "url": "https://site.com/",
            "inLanguage": "en-US",
            "publisher": {
                "@id": "https://site.com/#organization"
            }
        },
        {
            "@type": "BreadcrumbList",
            "@id": "https://site.com/posts/post-url#breadcrumb",
            "itemListElement": [
                {
                    "@type": "ListItem",
                    "item": {
                        "@type": "WebPage",
                        "@id": "https://site.com/#webpage",
                        "name": "Home",
                        "url": "https://site.com/"
                    },
                    "position": 1
                },
                {
                    "@type": "ListItem",
                    "item": {
                        "@type": "WebPage",
                        "@id": "https://site.com/posts/#webpage",
                        "name": "Post List",
                        "url": "https://site.com/posts/"
                    },
                    "position": 2
                },
                {
                    "@type": "ListItem",
                    "item": {
                        "@type": "WebPage",
                        "@id": "https://site.com/posts/post-url#webpage",
                        "name": "Current Post",
                        "url": "https://site.com/posts/post-url"
                    },
                    "position": 3
                }
            ],
            "numberOfItems": 3
        },
        {
            "@type": "ImageObject",
            "@id": "https://site.com/uploads/image-1.jpg#image",
            "url": "https://site.com/uploads/image-1.jpg",
            "inLanguage": "en-US",
            "contentUrl": "https://site.com/uploads/image-1.jpg",
            "height": "720",
            "width": "1280",
            "caption": "Image Name"
        },
        {
            "@type": "Person",
            "@id": "https://site.com/author#person",
            "name": "Author Name",
            "description": "Author Description",
            "image": {
                "@type": "ImageObject",
                "@id": "https://site.com/uploads/author-image.jpg#image",
                "url": "https://site.com/uploads/author-image.jpg",
                "inLanguage": "en-US",
                "contentUrl": "https://site.com/uploads/author-image.jpg",
                "height": "400",
                "width": "400",
                "caption": "Author Name"
            },
            "sameAs": [
                "https://twitter.com/AuthorId",
                "https://www.linkedin.com/company/AuthorId/"
            ],
            "url": "https://site.com/author"
        },
        {
            "@type": "WebPage",
            "@id": "https://site.com/url/#webpage",
            "name": "Page Title",
            "description": "Page Description",
            "image": {
                "@id": "https://site.com/uploads/image-1.jpg#image"
            },
            "mainEntityOfPage": "https://site.com/url/",
            "potentialAction": {
                "@type": "ReadAction",
                "target": "https://site.com/url/"
            },
            "url": "https://site.com/url/",
            "author": {
                "@id": "https://site.com/author#person"
            },
            "creator": {
                "@id": "https://site.com/author#person"
            },
            "dateCreated": "2021-07-24T03:21:49+00:00",
            "dateModified": "2021-07-24T03:21:49+00:00",
            "datePublished": "2021-07-24T03:21:49+00:00",
            "headline": "Page Title",
            "inLanguage": "en-US",
            "isPartOf": {
                "@id": "https://site.com/#website"
            },
            "keywords": [
                "SEO",
                "AspNetCore",
                "MVC",
                "RazorPages"
            ],
            "breadcrumb": {
                "@id": "https://site.com/posts/post-url#breadcrumb"
            },
            "primaryImageOfPage": {
                "@id": "https://site.com/uploads/image-1.jpg#image"
            }
        }
    ]
}
</script>
                

Note

Be sure to test your structured data using the google Rich Results Test tool during development, and the Rich result status reports after deployment, to monitor the health of your pages.