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

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sidio.Sitemap.Blazor

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

build NuGet Version

Installation

Add the package to your project.

Usage

Sitemap

Register services:

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

Register the middleware:

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

Stars

Watchers

Forks