From 02d0f2303075e55f32ae98d3b2fb88bb89dbefb2 Mon Sep 17 00:00:00 2001 From: saberzero1 Date: Sat, 28 Feb 2026 14:44:14 +0100 Subject: [PATCH] fix: use absolute asset paths for 404 page so it works in subdirectories --- quartz/plugins/pageTypes/dispatcher.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/quartz/plugins/pageTypes/dispatcher.ts b/quartz/plugins/pageTypes/dispatcher.ts index c49e22a29..d981f9801 100644 --- a/quartz/plugins/pageTypes/dispatcher.ts +++ b/quartz/plugins/pageTypes/dispatcher.ts @@ -76,7 +76,13 @@ async function emitPage( resources: StaticResources, ) { const cfg = ctx.cfg.configuration - const externalResources = pageResources(pathToRoot(slug), resources) + // For the 404 page, use an absolute base path so assets resolve correctly + // when the hosting provider serves 404.html from any URL depth + const baseDir = + slug === "404" + ? (new URL(`https://${cfg.baseUrl ?? "example.com"}`).pathname as FullSlug) + : pathToRoot(slug) + const externalResources = pageResources(baseDir, resources) const componentData: QuartzComponentProps = { ctx, fileData,