From c99b81f61f7e843069b92c1abcbb9e8dec600610 Mon Sep 17 00:00:00 2001 From: Ben Schreiber Date: Sun, 8 Feb 2026 21:57:50 -0800 Subject: [PATCH 1/2] pretty url fix --- crates/mdbook-html/front-end/templates/toc.js.hbs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/mdbook-html/front-end/templates/toc.js.hbs b/crates/mdbook-html/front-end/templates/toc.js.hbs index 1a9f751ccf..17c1cbee19 100644 --- a/crates/mdbook-html/front-end/templates/toc.js.hbs +++ b/crates/mdbook-html/front-end/templates/toc.js.hbs @@ -23,7 +23,8 @@ class MDBookSidebarScrollbox extends HTMLElement { link.href = path_to_root + href; } // The 'index' page is supposed to alias the first chapter in the book. - if (link.href === current_page + // We check both with and without the '.html' suffix to be robust against pretty URLs + if (link.href.replace(/\.html$/, '') === current_page.replace(/\.html$/, '') || i === 0 && path_to_root === '' && current_page.endsWith('/index.html')) { From 07cda662ded5268009acb7d38a5c7ce102369efb Mon Sep 17 00:00:00 2001 From: Ben Schreiber Date: Sun, 8 Feb 2026 21:59:23 -0800 Subject: [PATCH 2/2] comment --- crates/mdbook-html/front-end/templates/toc.js.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/mdbook-html/front-end/templates/toc.js.hbs b/crates/mdbook-html/front-end/templates/toc.js.hbs index 17c1cbee19..d5be5b1189 100644 --- a/crates/mdbook-html/front-end/templates/toc.js.hbs +++ b/crates/mdbook-html/front-end/templates/toc.js.hbs @@ -23,7 +23,7 @@ class MDBookSidebarScrollbox extends HTMLElement { link.href = path_to_root + href; } // The 'index' page is supposed to alias the first chapter in the book. - // We check both with and without the '.html' suffix to be robust against pretty URLs + // Check both with and without the '.html' suffix to be robust against pretty URLs if (link.href.replace(/\.html$/, '') === current_page.replace(/\.html$/, '') || i === 0 && path_to_root === ''