https://github.com/marthijn/sidio.sitemap.blazor
Sidio.Sitemap.Blazor is a lightweight .NET library for generating sitemaps in Blazor applications.
https://github.com/marthijn/sidio.sitemap.blazor
blazor sitemap sitemap-generator
Last synced: 8 months ago
JSON representation
Sidio.Sitemap.Blazor is a lightweight .NET library for generating sitemaps in Blazor applications.
- Host: GitHub
- URL: https://github.com/marthijn/sidio.sitemap.blazor
- Owner: marthijn
- License: mit
- Created: 2024-05-19T13:00:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-10-20T13:05:41.000Z (8 months ago)
- Last Synced: 2025-10-20T15:09:07.181Z (8 months ago)
- Topics: blazor, sitemap, sitemap-generator
- Language: C#
- Homepage:
- Size: 223 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Sidio.Sitemap.Blazor
Sidio.Sitemap.Blazor is a lightweight .NET library for generating sitemaps in Blazor server applications.
[](https://www.nuget.org/packages/Sidio.Sitemap.Blazor/)
# Versions
| | [Sidio.Sitemap.Core](https://github.com/marthijn/Sidio.Sitemap.Core)| [Sidio.Sitemap.AspNetCore](https://github.com/marthijn/Sidio.Sitemap.AspNetCore) | [Sidio.Sitemap.Blazor](https://github.com/marthijn/Sidio.Sitemap.Blazor) |
|------------|---------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| *NuGet* | [](https://www.nuget.org/packages/Sidio.Sitemap.Core/) | [](https://www.nuget.org/packages/Sidio.Sitemap.AspNetCore/) | [](https://www.nuget.org/packages/Sidio.Sitemap.Blazor/) |
| *Build* | [](https://github.com/marthijn/Sidio.Sitemap.Core/actions/workflows/build.yml)| [](https://github.com/marthijn/Sidio.Sitemap.AspNetCore/actions/workflows/build.yml) | [](https://github.com/marthijn/Sidio.Sitemap.Blazor/actions/workflows/build.yml) |
| *Coverage* | [](https://coveralls.io/github/marthijn/Sidio.Sitemap.Core?branch=main)| [](https://coveralls.io/github/marthijn/Sidio.Sitemap.AspNetCore?branch=main) | [](https://coveralls.io/github/marthijn/Sidio.Sitemap.Blazor?branch=main) |
| *Requirements*|.NET Standard, .NET 8+, | .NET 8+, AspNetCore|.NET 8+, AspNetCore, Blazor server|
# Installation
Add [the package](https://www.nuget.org/packages/Sidio.Sitemap.Blazor/) to your project.
# Usage
## Sitemap
Register services:
```csharp
builder.Services
.AddHttpContextAccessor()
.AddDefaultSitemapServices();
```
Register the middleware. Make sure to choose the correct namespace.
```csharp
using Sidio.Sitemap.Blazor;
app.UseSitemap();
```
Add the following attribute to your components (pages) to include them in the sitemap:
```cshtml
@* 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
* [Sidio.Sitemap.Core package](https://github.com/marthijn/Sidio.Sitemap.Core)