Web metadata configures how a browser and surrounding services present a site without changing the content displayed in the viewport. Use it to set the page title, icons, theme color, viewport behavior, manifest, and semantic or social information. section 3.3 section 3.9
Keep metadata accurate on every HTML document. During same-document route changes, update the title and active navigation state; set canonical URLs for indexable public pages. Social sharing metadata is best served with the page, since social apps may not read updates made in an existing browser session. section 3.9 section 11.1.3
function updateRouteMetadata({ title, canonicalPath }) {
document.title = title;
if (!canonicalPath) return;
let canonical = document.querySelector('link[rel="canonical"]');
if (!canonical) {
canonical = document.createElement("link");
canonical.rel = "canonical";
document.head.append(canonical);
}
canonical.href = new URL(canonicalPath, location.origin).href;
}
A small helper updates the document title and creates or updates a canonical link when a route supplies a canonical path. section 11.1.3






















