Produces a single, fully self-contained HTML report for a sitemap source,
modeled on the sitemap-validator reference renderer. Unlike read_sitemap()
(which returns a tidy tibble) and validate_sitemap() (which returns the
findings contract), report_sitemap() is the human-readable surface: it
consumes those existing outputs and renders them, and never re-implements
any parsing or validation itself.
Usage
report_sitemap(
x,
output = NULL,
mode = c("strict", "non-strict"),
urls = NULL,
findings = NULL,
title = NULL,
user_agent = default_user_agent(),
limits = fetch_limits(),
index_limits = NULL,
policy = request_policy()
)Arguments
- x
A single source: a sitemap URL (character) or a path to a local sitemap file. When both
urlsandfindingsare supplied,xis used only as the displayed source label.- output
Optional path to write the HTML file to. When supplied, the report is written there (UTF-8) and the path is returned invisibly; otherwise the HTML is returned as an htmltools::HTML string.
- mode
"strict"(the default) or"non-strict", passed tovalidate_sitemap()whenfindingsis not supplied.- urls
Optional precomputed
read_sitemap()result (a tibble with thesourcesattribute). WhenNULL(the default) it is computed fromx.- findings
Optional precomputed
validate_sitemap()findings tibble. WhenNULL(the default) it is computed fromx.- title
The HTML document
<title>. Defaults to a title derived fromx.- user_agent
The User-Agent header for HTTP fetches. Defaults to the package User-Agent.
- limits
Network limits for HTTP fetches, as from
fetch_limits().- index_limits
Sitemapindex-expansion bounds (recursion depth and per-index child-count cap), as from
index_limits(). Defaults toindex_limits().- policy
A request policy applied to every HTTP hop (root, robots.txt, discovery, redirects, and index children). Defaults to the no-op policy.
Value
If output is supplied, the output path, invisibly. Otherwise, the
report HTML as an htmltools::HTML character string.
Details
The report contains a hero banner (source, overall status, URL/index/sitemap
counts), a per-source sitemap table (format, HTTP status, URL count, and
lastmod/priority/changefreq presence), lastmod coverage cards with a
by-month histogram, a collapsible URL folder tree grouped by path segment, a
severity dashboard, the findings grouped by validation layer (deduplicated by
code, with evidence excerpts), and a searchable, sortable, CSV-exportable URL
table.
The output is entirely self-contained: all CSS, JavaScript (search, sort,
CSV export, tree toggle, and a light/dark theme toggle), and data are
inlined, so the file references no external hosts and works offline. The
palette follows the viewer's prefers-color-scheme by default; the in-page
toggle stamps a data-theme attribute on the root element that wins in both
directions.
By default the source x is both read (via read_sitemap(), for the URL
rows and per-source metadata) and validated (via validate_sitemap(), for
the findings). To avoid re-fetching a URL source, or to render results you
have already computed, pass them via urls and/or findings; in that case
x is used only as the report's source label.
See also
read_sitemap() and validate_sitemap() for the underlying data.
Examples
# Render a report for a local sitemap file to a temporary HTML file.
xml <- paste0(
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
'<url><loc>https://example.com/</loc>',
'<lastmod>2024-01-01</lastmod></url>',
'<url><loc>https://example.com/about</loc></url>',
'</urlset>'
)
path <- tempfile(fileext = ".xml")
writeLines(xml, path)
out <- tempfile(fileext = ".html")
report_sitemap(path, output = out)
# Render directly from a sitemap URL (fetches twice: read + validate).
# report_sitemap("https://example.com/sitemap.xml", output = "report.html")
# Reuse results you have already computed to avoid re-fetching.
# u <- read_sitemap("https://example.com/sitemap.xml")
# f <- validate_sitemap("https://example.com/sitemap.xml")
# report_sitemap(
# "example.com", urls = u, findings = f, output = "report.html"
# )