[Bug]: Logo link goes stale after SPA navigation and points to the current page
docmd version
0.9.8
Node.js version
v25.2.1
OS/Browser
macOS / Chrome
Description
With layout.spa: true, the sidebar logo keeps the relative href of the first page the visitor opened. The template builds it with buildRelativeUrl('/') (packages/ui/templates/layout.ejs:119), so it is ./ on the home page and ../ on /guide/.
On SPA navigation, navigateTo in packages/ui/assets/js/docmd-main.js swaps the content and re-resolves the .sidebar-nav links (line 967). .sidebar-header is not swapped or re-resolved, so the logo keeps ./, which the browser now resolves against the new URL. The logo then links to the current page: the first click only reloads it, the second goes home.
When no logo is set, the site title link (layout.ejs:135) is built the same way.
Steps to Reproduce
- A site with
logoconfigured andlayout.spa: true. - Open the home page
/. - Click a page in the sidebar, e.g.
/guide/. - The logo now links to
/guide/. Clicking it reloads/guide/; clicking it again opens/.
Expected Behavior
The logo always links to the home page (or to logo.href).
A possible fix: in navigateTo, re-resolve the .sidebar-header a hrefs against data.finalUrl, the same way as the sidebar links. As a workaround we use a customJs file that makes the logo link absolute on load.
Resolved in v0.9.9.
The SPA router navigation lifecycle now re-evaluates and dynamically preserves the #site-logo a root href on page transitions, ensuring the logo always reliably links back to the documentation home page regardless of navigation history depth.
Verified with integration contract tests in tests/cli-contracts/url-routing.test.js.
Give it a try.
Thanks, works like a charm!