SyntaxCircus.Blazor.Seo
0.1.4
dotnet add package SyntaxCircus.Blazor.Seo --version 0.1.4
NuGet\Install-Package SyntaxCircus.Blazor.Seo -Version 0.1.4
<PackageReference Include="SyntaxCircus.Blazor.Seo" Version="0.1.4" />
<PackageVersion Include="SyntaxCircus.Blazor.Seo" Version="0.1.4" />
<PackageReference Include="SyntaxCircus.Blazor.Seo" />
paket add SyntaxCircus.Blazor.Seo --version 0.1.4
#r "nuget: SyntaxCircus.Blazor.Seo, 0.1.4"
#:package SyntaxCircus.Blazor.Seo@0.1.4
#addin nuget:?package=SyntaxCircus.Blazor.Seo&version=0.1.4
#tool nuget:?package=SyntaxCircus.Blazor.Seo&version=0.1.4
SyntaxCircus.Blazor.Seo
SEO building blocks for Blazor Server marketing sites — meta/OG/Twitter tags, typed Schema.org JSON-LD, and a canonical URL builder. Sitemap.xml, robots.txt, and canonical-host redirect are thin wrappers over SyntaxCircus.AspNetCore.Common, which this package depends on rather than reimplementing.
No support guaranteed. Published as-is and maintained on a best-effort basis. Issues and PRs are welcome, but there's no SLA — fork it or vendor what you need if that's not enough.
Breaking change from previous versions:
SitemapEndpoint,RobotsTxtEndpoint, andCanonicalHostMiddlewareare gone, replaced bySeoEndpointExtensions(MapSeoSitemap/MapSeoRobotsTxt) and AspNetCore.Common's canonical-host redirect. The canonical-host redirect is now an allow-list (CanonicalHost:LegacyHosts), not a deny-by-default redirect of every mismatched host. See CHANGELOG.md for details.
Setup
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSyntaxCircusSeo(builder.Configuration); // binds "Seo", "Support", "CanonicalHost", "SearchIndexing"
var app = builder.Build();
app.UseSyntaxCircusSeo(); // canonical-host redirect + X-Robots-Tag search-indexing headers
app.MapSeoSitemap(
staticEntries:
[
new SitemapEntry(builder.Configuration["Seo:BaseUrl"] + "/", DateOnly.FromDateTime(DateTime.UtcNow), SitemapChangeFrequency.Weekly, 1.0),
new SitemapEntry(builder.Configuration["Seo:BaseUrl"] + "/about", DateOnly.FromDateTime(DateTime.UtcNow)),
],
dynamicEntriesProvider: async (services, ct) =>
{
var catalog = services.GetRequiredService<IMyCatalogService>();
return catalog.GetEntries().Select(e => new SitemapEntry($"{baseUrl}/items/{e.Slug}", DateOnly.FromDateTime(e.UpdatedAt))).ToArray();
});
app.MapSeoRobotsTxt();
SitemapEntry and SitemapChangeFrequency come from SyntaxCircus.AspNetCore.Common — see that package for the full sitemap/robots.txt/canonical-host/search-indexing option surface (CanonicalHost:CanonicalHost, CanonicalHost:LegacyHosts, SearchIndexing:BlockRobotsAndSitemap, etc.).
Configuration
| Section | Purpose | Owned by |
|---|---|---|
Seo |
BaseUrl, SiteName, DefaultDescription, DefaultOgImage, DefaultLocale, TwitterHandle, LogoUrl, SameAs |
Blazor.Seo |
Support |
Optional site support/contact info — Email, IssueTrackerUrl, IssueTemplateUrl, OwnerContactUrl, OwnerDisplayName |
Blazor.Seo |
CanonicalHost |
CanonicalHost, LegacyHosts, ForceHttps, Permanent |
AspNetCore.Common |
SearchIndexing |
BlockPageMetadata, RobotsDirective, BlockRobotsAndSitemap, ExcludedPaths |
AspNetCore.Common |
Per-page meta tags
<SeoHead
Title="Pricing"
Description="Plans and pricing."
RelativeUrl="/pricing"
StructuredData="PageSchemas" />
@code {
private IReadOnlyList<object> PageSchemas =>
[
new OrganizationSchema(
Name: "Acme",
Url: "https://acme.example",
Logo: "https://acme.example/logo.png"),
new BreadcrumbListSchema(
[new BreadcrumbItem(1, "Home", "https://acme.example/"), new BreadcrumbItem(2, "Pricing", "https://acme.example/pricing")]),
];
}
SeoHead sets the document title and fills in description, canonical link, robots directives, and Open Graph/Twitter tags from SeoOptions plus whatever you override per-page. Its optional StructuredData parameter renders each supplied object as a JSON-LD block in the document head. JsonLd remains available when you prefer to place a single schema directly; both accept typed records from Schemas.cs (OrganizationSchema, WebSiteSchema, PersonSchema, CreativeWorkSchema, SoftwareApplicationSchema, BookSchema, BreadcrumbListSchema, FaqPageSchema) or your own POCO.
Notes
MapSeoSitemap/MapSeoRobotsTxtreturnIEndpointRouteBuilder— the same builder you called them on, passed straight through from AspNetCore.Common'sMapSitemap/MapRobotsTxt, not a per-routeIEndpointConventionBuilder. Nothing can be chained onto the result (no.CacheOutput(...),.WithName(...), etc.) — that per-route builder isn't exposed by AspNetCore.Common's API. Pass thecacheDurationparameter instead to set aCache-Control: public, max-age=...response header directly, e.g.app.MapSeoSitemap(entries, cacheDuration: TimeSpan.FromHours(1)).- Neither endpoint is registered under a route name (no
LinkGenerator/Url.RouteUrl(...)support) — the previous versions'.WithName("SyntaxCircusSitemap")/.WithName("SyntaxCircusRobotsTxt")calls had nowhere to attach once mapping moved into AspNetCore.Common. Reference/sitemap.xml//robots.txtby literal path if you need to link to them. ISeoUrlBuilder(injectable) resolves relative URLs againstSeo:BaseUrland can compute the canonical URL for the current request.MapSeoRobotsTxtuses it to auto-append theSitemap:line.SearchIndexing:BlockRobotsAndSitemap(AspNetCore.Common) makesMapSeoRobotsTxtreturn a deny-all body andMapSeoSitemapreturn 404 — a single kill-switch for taking a site out of search indexing.
Contributing
Issues and pull requests are welcome:
- Keep changes focused, with a clear description of the behavior change.
- Match the existing code style (see
.editorconfig). - Call out any breaking changes to the public API in your PR description.
License
MIT — see LICENSE.txt.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- SyntaxCircus.AspNetCore.Common (>= 0.1.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.