Skip to content

Sidio.Sitemap.Blazor is a lightweight .NET library for generating sitemaps in Blazor applications.

License

Notifications You must be signed in to change notification settings

marthijn/Sidio.Sitemap.Blazor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sidio.Sitemap.Blazor

Sidio.Sitemap.Blazor is a lightweight .NET library for generating sitemaps in Blazor server applications.

build NuGet Version Coverage Status

Installation

Add the package to your project.

Usage

Sitemap

Register services:

builder.Services
    .AddHttpContextAccessor()
    .AddDefaultSitemapServices<HttpContextBaseUrlProvider>();

Register the middleware. Make sure to choose the correct namespace.

using Sidio.Sitemap.Blazor;

app.UseSitemap();

Add the following attribute to your components (pages) to include them in the sitemap:

@* default *@
@attribute [Sitemap]

@* override route url *@
@attribute [Sitemap("/custom-url")]

@* add change frequency, priority and last modified date *@
@attribute [Sitemap(ChangeFrequency.Daily, 0.5, "2024-01-01")]

The sitemap is accessible at [domain]/sitemap.xml.

FAQ

  • Exception: Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting to activate 'Sidio.Sitemap.AspNetCore.HttpContextBaseUrlProvider'.
    • Solution: call services.AddHttpContextAccessor(); to register the IHttpContextAccessor.

See also

About

Sidio.Sitemap.Blazor is a lightweight .NET library for generating sitemaps in Blazor applications.

Topics

Resources

License

Security policy

Stars

Watchers

Forks