Skip to content

Generating sitemap.xml from route table#1941

Closed
tomasherceg wants to merge 4 commits intomainfrom
feature/google-sitemap
Closed

Generating sitemap.xml from route table#1941
tomasherceg wants to merge 4 commits intomainfrom
feature/google-sitemap

Conversation

@tomasherceg
Copy link
Copy Markdown
Member

I added a mechanism to auto-generate Sitemaps based on metadata in the route table.

  1. Turning the sitemap on for all routes (except for DotVVM routes that are always excluded, and also routes without virtualPath - they must be included explicitly):
config.RouteTable.WithDefaultSitemapOptions(sitemap =>
{
    sitemap.ChangeFrequency = ChangeFrequency.Daily;
    sitemap.Priority = 1;
});
  1. The settings may be overridden on route groups. Unfortunately, I had to change the return type of AddGroup, otherwise there would be no easy way to access the route group. However, I don't think it will affect many people.
routeTable.AddGroup(..., opt =>
    {
        ...
    })
    .WithDefaultSitemapOptions(sitemap =>
    {
        sitemap.Exclude = true;
    });
  1. You can specify a provider to produce all possible values for parameters. The provider must be registered in IServiceCollection. It should implement IRouteParameterValuesProvider, and return a list of "dictionaries" containing values for each parameter (for each culture, if route localization is used).
config.RouteTable.Add("BlogDetail", "blog/{Slug}", ...)
    .WithSitemapOptions(sitemap =>
    {
        sitemap.UseParameterValuesProvider<BlogDetailParameterValuesProvider>();
    });
  1. The last modified date is by default inferred from the last modification of the entry assembly (which will be the web application DLL). It is possible to override.

  2. The routes may be explicitly included or excluded by setting their sitemap.Exclude property. You can also fine-tune the Priority, ChangeFrequency, and LastModified.

@tomasherceg
Copy link
Copy Markdown
Member Author

Abandoning in favor of #1953

@tomasherceg tomasherceg deleted the feature/google-sitemap branch August 31, 2025 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant