Router Discovery source for sitemap generation.
Automatically scans all GET routes from the parent application's router and includes them in the sitemap. Routes can be filtered using exclude patterns and include-only patterns.
Settings
sitemap_router_discovery_enabled- Enable/disable auto-discovery (default: true)sitemap_router_discovery_exclude_patterns- JSON array of regex patterns to excludesitemap_router_discovery_include_only- JSON array of regex patterns for whitelist modesitemap_protected_pipelines- JSON array of pipeline names that require authentication
Pattern Syntax
Exclude and include-only patterns are regular expressions (compiled with
Regex.compile/1), not shell globs. A bare "*" is an invalid regex and is
ignored with a logged warning — use ".*" to match everything or "^/prefix"
to match a path prefix. Invalid patterns never silently disable the source.
Default Exclusions
By default, the following patterns are excluded:
^/admin- Admin routes^/api- API endpoints^/phoenix_kit- PhoenixKit admin routes^/dev- Development routes^/__- Internal/technical routes (double-underscore convention, e.g. Publishing's internal dispatch scope)^/maintenance$- PhoenixKit's reserved maintenance page route:[a-z_]+- Routes with parameters\*- Wildcard routes
Additionally, routes using authentication pipelines are automatically excluded:
:phoenix_kit_require_authenticated- Routes requiring user authentication:phoenix_kit_admin_only- Routes requiring admin/owner role:authenticated- Common name for authentication pipeline:require_authenticated- Alternative authentication pipeline name:admin- Common admin pipeline name:admin_only- Alternative admin pipeline name
Custom pipelines can be added via sitemap_protected_pipelines setting.
LiveView routes using authentication on_mount hooks are also excluded:
{PhoenixKitWeb.Users.Auth, :phoenix_kit_ensure_authenticated_scope}- Ensures user is authenticated{PhoenixKitWeb.Users.Auth, :phoenix_kit_redirect_if_authenticated_scope}- Redirects if already authenticated
Examples
# Enable auto-discovery (default)
Settings.update_boolean_setting("sitemap_router_discovery_enabled", true)
# Custom exclude patterns
Settings.update_setting("sitemap_router_discovery_exclude_patterns",
Jason.encode!(["^/admin", "^/api", "^/private"]))
# Whitelist mode - only include specific paths
Settings.update_setting("sitemap_router_discovery_include_only",
Jason.encode!(["^/products", "^/categories"]))
# Custom protected pipelines (add to defaults)
Settings.update_setting("sitemap_protected_pipelines",
Jason.encode!(["my_auth_pipeline", "member_only"]))Sitemap Properties
- Priority: 0.5 (default for discovered routes)
- Change frequency: weekly
- Category: "Routes"
Summary
Functions
Returns the built-in default exclude patterns.
Returns the built-in default protected pipelines.
Returns the subset of patterns that fail to compile as regexes.
Functions
@spec default_exclude_patterns() :: [String.t()]
Returns the built-in default exclude patterns.
These apply whenever sitemap_router_discovery_exclude_patterns is unset.
Once that setting is saved (even as an empty list), it replaces this list
entirely rather than adding to it. Exposed so the settings UI can show
admins what's excluded today, before they touch the setting.
@spec default_protected_pipelines() :: [atom()]
Returns the built-in default protected pipelines.
Unlike exclude patterns, sitemap_protected_pipelines only adds to this
list — these defaults always apply. Exposed so the settings UI can show
admins which pipelines are already protected without configuration.
Returns the subset of patterns that fail to compile as regexes.
Mirrors the same Regex.compile/1 check compile_patterns/2 applies at
collection time, so a pattern accepted here is guaranteed not to be
silently dropped later. Used by the settings UI to reject invalid
exclude/include-only patterns before saving, instead of persisting them
and only discovering the problem in the logs.
Examples
iex> PhoenixKit.Modules.Sitemap.Sources.RouterDiscovery.invalid_patterns(["^/admin", "*"])
["*"]