{"id":32440523,"url":"https://github.com/marthijn/sidio.sitemap.aspnetcore","last_synced_at":"2025-10-26T01:48:00.579Z","repository":{"id":222132804,"uuid":"755172464","full_name":"marthijn/Sidio.Sitemap.AspNetCore","owner":"marthijn","description":"Sidio.Sitemap.AspNetCore is a lightweight .NET library for generating sitemaps and a sitemap index in ASP .NET Core applications.","archived":false,"fork":false,"pushed_at":"2025-10-09T05:20:34.000Z","size":1233,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T19:45:27.299Z","etag":null,"topics":["asp-net-core","generating-sitemaps","sitemap","sitemap-files","sitemap-generator"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marthijn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-02-09T15:20:27.000Z","updated_at":"2025-10-09T05:20:30.000Z","dependencies_parsed_at":"2024-02-12T15:45:18.439Z","dependency_job_id":"5c14f14e-a41a-4268-a576-c9dc3ff6615c","html_url":"https://github.com/marthijn/Sidio.Sitemap.AspNetCore","commit_stats":null,"previous_names":["marthijn/sitemap.aspnetcore","marthijn/sidio.sitemap.aspnetcore"],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/marthijn/Sidio.Sitemap.AspNetCore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marthijn%2FSidio.Sitemap.AspNetCore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marthijn%2FSidio.Sitemap.AspNetCore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marthijn%2FSidio.Sitemap.AspNetCore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marthijn%2FSidio.Sitemap.AspNetCore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marthijn","download_url":"https://codeload.github.com/marthijn/Sidio.Sitemap.AspNetCore/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marthijn%2FSidio.Sitemap.AspNetCore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281047795,"owners_count":26435124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net-core","generating-sitemaps","sitemap","sitemap-files","sitemap-generator"],"created_at":"2025-10-26T01:47:59.632Z","updated_at":"2025-10-26T01:48:00.569Z","avatar_url":"https://github.com/marthijn.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Sidio.Sitemap.AspNetCore\n=============\nSidio.Sitemap.AspNetCore is a lightweight .NET library for generating sitemaps and a sitemap index in ASP .NET Core applications.\n\nIn addition to sitemap and sitemap index generation, news, images and video extensions are also supported.\n\n[![NuGet Version](https://img.shields.io/nuget/v/Sidio.Sitemap.AspNetCore)](https://www.nuget.org/packages/Sidio.Sitemap.AspNetCore/)\n\n# Versions\n\n|            | [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)                                                                                                                                                           |\n|------------|---------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| *NuGet*    | [![NuGet Version](https://img.shields.io/nuget/v/Sidio.Sitemap.Core)](https://www.nuget.org/packages/Sidio.Sitemap.Core/) | [![NuGet Version](https://img.shields.io/nuget/v/Sidio.Sitemap.AspNetCore)](https://www.nuget.org/packages/Sidio.Sitemap.AspNetCore/)                                                      | [![NuGet Version](https://img.shields.io/nuget/v/Sidio.Sitemap.Blazor)](https://www.nuget.org/packages/Sidio.Sitemap.Blazor/)                                                      |\n| *Build*    | [![build](https://github.com/marthijn/Sidio.Sitemap.Core/actions/workflows/build.yml/badge.svg)](https://github.com/marthijn/Sidio.Sitemap.Core/actions/workflows/build.yml)| [![build](https://github.com/marthijn/Sidio.Sitemap.AspNetCore/actions/workflows/build.yml/badge.svg)](https://github.com/marthijn/Sidio.Sitemap.AspNetCore/actions/workflows/build.yml)   | [![build](https://github.com/marthijn/Sidio.Sitemap.Blazor/actions/workflows/build.yml/badge.svg)](https://github.com/marthijn/Sidio.Sitemap.Blazor/actions/workflows/build.yml)   |\n| *Coverage* | [![Coverage Status](https://coveralls.io/repos/github/marthijn/Sidio.Sitemap.Core/badge.svg?branch=main)](https://coveralls.io/github/marthijn/Sidio.Sitemap.Core?branch=main)| [![Coverage Status](https://coveralls.io/repos/github/marthijn/Sidio.Sitemap.AspNetCore/badge.svg?branch=main)](https://coveralls.io/github/marthijn/Sidio.Sitemap.AspNetCore?branch=main) | [![Coverage Status](https://coveralls.io/repos/github/marthijn/Sidio.Sitemap.Blazor/badge.svg?branch=main)](https://coveralls.io/github/marthijn/Sidio.Sitemap.Blazor?branch=main) |\n| *Requirements*|.NET Standard, .NET 8+, | .NET 8+, AspNetCore|.NET 8+, AspNetCore, Blazor server|\n\n# Installation\nAdd [the package](https://www.nuget.org/packages/Sidio.Sitemap.AspNetCore/) to your project.\n\n# Usage\nThere are two ways to generate sitemaps: manually or by using middleware. When using middleware, the sitemap is generated automatically.\n\n## Building sitemaps manually\n### Sitemap\n```csharp\n// di setup\nservices.AddHttpContextAccessor();\nservices.AddDefaultSitemapServices\u003cHttpContextBaseUrlProvider\u003e();\n\n// controller\n[HttpGet]\npublic IActionResult Sitemap()\n{\n    var nodes = new List\u003cSitemapNode\u003e { new (\"page.html\"), SitemapNode.Create(Url.Action(\"Index\")) };\n    var sitemap = new Sitemap(nodes);\n    return new SitemapResult(sitemap);\n}\n```\n\n### Sitemap and sitemap index\n```csharp\n[Route(\"sitemap.xml\")]\npublic IActionResult SitemapIndex()\n{\n    var sitemapIndex = new SitemapIndex();\n    \n    // basic usage:\n    sitemapIndex.Add(new SitemapIndexNode(Url.Action(\"Sitemap1\")));\n    \n    // or: this extension function fixes the null reference warning\n    // on the line above:\n    var addResult = sitemapIndex.TryAdd(Url.Action(\"Sitemap2\"));\n    \n    // or: use the Create function\n    sitemapIndex.Add(SitemapIndexNode.Create(Url.Action(\"Sitemap1\")));\n    \n    return new SitemapResult(sitemapIndex);\n}\n\n[Route(\"sitemap-1.xml\")]\npublic IActionResult Sitemap1()\n{\n    // ...\n}\n\n[Route(\"sitemap-2.xml\")]\npublic IActionResult Sitemap2()\n{\n    // ...\n}\n```\n\n### Advanced setup and extensions\nSee the [Sidio.Sitemap.Core package documentation](https://github.com/marthijn/Sidio.Sitemap.Core) to read more about additional properties\nand sitemap extensions (i.e. news, images and videos).\n\n## Using middleware\nBy using the `SitemapMiddlware` the sitemap is generated automatically using reflection. \nCurrently only ASP .NET Core controllers and actions are supported. Razor pages will be supported in the future.\n\n### Setup\nIn `Program.cs`, add the following:\n```csharp\n// di setup\nbuilder.Services.\n    .AddHttpContextAccessor()\n    .AddDefaultSitemapServices\u003cHttpContextBaseUrlProvider\u003e()\n    .AddSitemapMiddleware(\n        options =\u003e\n        {\n            options.EndpointInclusionMode = EndpointInclusionMode.OptIn;\n            options.CacheEnabled = false; // (optional) default is false, set to true to enable caching\n            options.CacheAbsoluteExpirationInMinutes = 60; // (optional) default is 60 minutes\n        })\n\n// use the middleware \napp.UseSitemap();\n```\n\n### Controller and action attributes\nDecorate your controllers and/or actions with the `[SitemapInclude]` or `[SitemapExclude]` attribute.\n\nWhen using `OptIn` mode, only controllers and/or actions decorated with `[SitemapInclude]` will be included in the sitemap.\n```csharp\n[SitemapInclude] // this action will be included in the sitemap\npublic IActionResult Index()\n{\n    return View();\n}\n```\n\nWhen using `OptOut` mode, controllers and/or actions decorated with `[SitemapExclude]` will be excluded from the sitemap.\n```csharp\n[SitemapExclude] // this action will not be included in the sitemap\npublic IActionResult Index()\n{\n    return View();\n}\n```\n\n#### API controllers\nIndexing of API controllers is supported as well by configuring the `SitemapMiddleware`:\n```csharp\nbuilder.Services\n    // ...\n    .AddSitemapMiddleware(\n        options =\u003e\n        {\n            // ...\n            options.IncludeApiControllers = true;\n        })\n```\n\n### Razor pages\nSimilar to controllers and actions, the attributes can be used in razor pages:\n```cshtml\n@page\n@attribute [SitemapExclude]\n@model LoginModel\n@{\n    ViewData[\"Title\"] = \"My login page\";\n}\n```\n\n### Caching\nConfigure the [`IDistributedCache`](https://learn.microsoft.com/en-us/aspnet/core/performance/caching/distributed) to use caching of the Sitemap.\n\n# FAQ\n\n* Exception: `Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting to activate 'Sidio.Sitemap.AspNetCore.HttpContextBaseUrlProvider'.` \n  * Solution: call `services.AddHttpContextAccessor();` to register the `IHttpContextAccessor`.\n\n# See also\n* [Sidio.Sitemap.Core package](https://github.com/marthijn/Sidio.Sitemap.Core)\n* [Sidio.Sitemap.Blazor package](https://github.com/marthijn/Sidio.Sitemap.Blazor) for Blazor support.\n\n# Used by\n- [Drammer.com](https://drammer.com)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarthijn%2Fsidio.sitemap.aspnetcore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarthijn%2Fsidio.sitemap.aspnetcore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarthijn%2Fsidio.sitemap.aspnetcore/lists"}