This documentation is also published as Markdown for efficient machine reading: the whole site is indexed at /llms.txt, and every page has a clean Markdown copy under /_llms/. These are generated from the same source and cost far fewer tokens to read than this rendered HTML.

Skip to main content Skip to navigation

SitemapService Pennington.Feeds

Generates sitemap XML for the /sitemap.xml endpoint. Uses AsyncLazy for lazy, thread-safe computation. When managed by FileWatchDependencyFactory, the instance is recreated on file changes — trusts IContentService for fresh metadata.

Enumerates every DiscoverAsync result. Markdown sources carry the front matter their content service already parsed at discovery time, so Date (lastmod) is read straight off Metadata — no re-parse, and no risk of applying one source's front-matter type to another's files. Programmatic / Razor page sources surface metadata only at render time and carry none on the discovered item, so their routes are emitted with no extra metadata.

Sitemap, search index, and llms.txt each answer a different question, so they intentionally run different filtering paths:

  • (this service) — every canonical HTML URL a crawler should index. Sourced from DiscoverAsync because Razor / programmatic routes with no TOC entry still need to appear. Per-page search: / llms: opt-outs are honored here: those are search UX preferences, not SEO directives.
  • — enumerates GetIndexableEntriesAsync, which carries ExcludeFromSearch / ExcludeFromLlms flags sourced from search: / llms: front-matter.

Keep these two paths distinct — collapsing them would either leak search opt-outs into the sitemap (bad for SEO) or force every Razor/programmatic source to grow a TOC entry purely so it shows up in the sitemap.

Constructors

SitemapService

#
public SitemapService(IEnumerable<IContentService> contentServices, LocalizationOptions localization, SitemapBuilder builder)

Initializes the service and prepares lazy sitemap generation driven by the provided builder.

Parameters

contentServices IEnumerable<IContentService>
localization LocalizationOptions
builder SitemapBuilder

Methods

GetSitemapXmlAsync

#
public Task<string> GetSitemapXmlAsync()

Returns the serialized sitemap XML, generating it on first access and caching the result.

Returns

Task<string>

OnFileChanged

#
public FileWatchResponse OnFileChanged(FileChangeNotification change)

Called on the file-watcher thread for every watched change. Must be quick and thread-safe.

Parameters

change FileChangeNotification

Returns

FileWatchResponse

Pennington.Feeds.SitemapService

namespace Pennington.Feeds;

/// Generates sitemap XML for the /sitemap.xml endpoint. Uses AsyncLazy for lazy, thread-safe computation. When managed by FileWatchDependencyFactory, the instance is recreated on file changes — trusts IContentService for fresh metadata. Enumerates every DiscoverAsync result. Markdown sources carry the front matter their content service already parsed at discovery time, so Date (lastmod) is read straight off Metadata — no re-parse, and no risk of applying one source's front-matter type to another's files. Programmatic / Razor page sources surface metadata only at render time and carry none on the discovered item, so their routes are emitted with no extra metadata. Sitemap, search index, and llms.txt each answer a different question, so they intentionally run different filtering paths:
  • (this service) — every canonical HTML URL a crawler should index. Sourced from DiscoverAsync because Razor / programmatic routes with no TOC entry still need to appear. Per-page search: / llms: opt-outs are honored here: those are search UX preferences, not SEO directives.
  • — enumerates GetIndexableEntriesAsync, which carries ExcludeFromSearch / ExcludeFromLlms flags sourced from search: / llms: front-matter.
Keep these two paths distinct — collapsing them would either leak search opt-outs into the sitemap (bad for SEO) or force every Razor/programmatic source to grow a TOC entry purely so it shows up in the sitemap. public class SitemapService { /// Returns the serialized sitemap XML, generating it on first access and caching the result.
public Task<string> GetSitemapXmlAsync()
; /// Called on the file-watcher thread for every watched change. Must be quick and thread-safe.
public FileWatchResponse OnFileChanged(FileChangeNotification change)
; /// Initializes the service and prepares lazy sitemap generation driven by the provided builder.
public SitemapService(IEnumerable<IContentService> contentServices, LocalizationOptions localization, SitemapBuilder builder)
; }