FoxLearn.AspNetCore.JsonLd
1.0.1
See the version list below for details.
dotnet add package FoxLearn.AspNetCore.JsonLd --version 1.0.1
NuGet\Install-Package FoxLearn.AspNetCore.JsonLd -Version 1.0.1
<PackageReference Include="FoxLearn.AspNetCore.JsonLd" Version="1.0.1" />
<PackageVersion Include="FoxLearn.AspNetCore.JsonLd" Version="1.0.1" />
<PackageReference Include="FoxLearn.AspNetCore.JsonLd" />
paket add FoxLearn.AspNetCore.JsonLd --version 1.0.1
#r "nuget: FoxLearn.AspNetCore.JsonLd, 1.0.1"
#:package FoxLearn.AspNetCore.JsonLd@1.0.1
#addin nuget:?package=FoxLearn.AspNetCore.JsonLd&version=1.0.1
#tool nuget:?package=FoxLearn.AspNetCore.JsonLd&version=1.0.1
FoxLearn.AspNetCore.JsonLd
It's a lightweight .NET library that automatically inserts <script>
tags with the MIME type application/ld+json
into the <head>
section of your HTML. This helps search engines better understand your web pages by adding structured data (JSON-LD), which can improve SEO and enhance how your content appears in search results.
Features
- 🤖 Automatically injects structured data (JSON-LD)
- 🔍 Enhances SEO and search visibility
- ⚙️ Easy integration with ASP.NET Core applications
- 🧩 Supports custom schema definitions using Schema.org formats
- ✨ No manual HTML edits required
Installation
Install via the .NET CLI:
dotnet add package FoxLearn.AspNetCore.JsonLd
Or via the NuGet UI in Visual Studio by searching for FoxLearn.AspNetCore.JsonLd
Usage
Register the services in Startup.cs
or Program.cs
:
builder.Services.ConfigureJsonLd<FoxLearn.JsonLd.Schema.Organization>(options =>
{
options.Name = "FoxLearn";
options.Url = new Uri("https://foxlearn.com");
options.LegalName = "FoxLearn";
options.Logo = new Uri("https://foxlearn.com/img/logo.png");
options.Description = "Welcome to foxlearn.com! This site is a blog about everything that matters in the world of programming.";
options.ContactPoint = new List<ContactPoint>()
{
new ContactPoint() { ContactType = "Customer Service", Name = "Tan Lee", Email = "example@gmail.com"}
};
options.Founder = new List<IPerson>()
{
new Person() { Name = "Tan Lee"}
};
options.FoundingDate = new FoxLearn.JsonLd.Date(2016, 01, 01);
options.Email = "example@gmail.com";
});
// You can easily configure JSON-LD serialization options here.
builder.Services.Configure<JsonLdOptions>(options =>
{
options.SerializerOptions.WriteIndented = true;
});
builder.Services.AddScoped<IJsonLdBuilder, JsonLdBuilder>(); // Required
var app = builder.Build();
...
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.MapStaticAssets();
app.UseJsonLd();
// Or you can configure JSON-LD serialization options as shown below.
//app.UseJsonLd(options =>
//{
// options.SerializerOptions.WriteIndented = true;
//});
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}")
.WithStaticAssets();
Add structured data in your controller or view model:
private readonly IJsonLdBuilder _jsonLd;
public HomeController(IJsonLdBuilder jsonLd)
{
_jsonLd = jsonLd;
}
public IActionResult Category(string categoryName)
{
BreadcrumbList breadcrumbList = new()
{
Name = "Breadcrumb",
ItemListElement = new List<IListItem>()
{
new ListItem { Position = 1, Name = "Home", Url = new Uri($"{Request.Scheme}://{Request.Host}") },
new ListItem { Position = 2, Name = "Category", Url = new Uri($"{Request.Scheme}://{Request.Host}/{categoryName}") }
}
};
_jsonLd.Add(breadcrumbList);
return View();
}
Example Output
<script type="application/ld+json">
{
"@context":"https://schema.org",
"@type": "Organization",
"email": "example@gmail.com",
"founder": {
"@type": "Person",
"name": "Tan Lee"
},
"foundingDate": "2016-01-01",
"legalName": "FoxLearn",
"contactPoint": {
"@type": "ContactPoint",
"email": "example@gmail.com",
"contactType": "Customer Service",
"name": "Tan Lee"
},
"logo": "https://foxlearn.com/img/logo.png",
"url": "https://foxlearn.com",
"name": "FoxLearn",
"description": "Welcome to foxlearn.com! This site is a blog about everything that matters in the world of programming."
}
</script>
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- FoxLearn.JsonLd (>= 1.0.2)
-
net7.0
- FoxLearn.JsonLd (>= 1.0.2)
-
net8.0
- FoxLearn.JsonLd (>= 1.0.2)
-
net9.0
- FoxLearn.JsonLd (>= 1.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.