Skip to content

fix: 3 path/route-resolution bugs surfaced when deploying with 0.5.0 - #59

Merged
rachfop merged 3 commits into
rachfop:mainfrom
AlexAdiaconitei:main
Jul 22, 2026
Merged

rachfop merged 3 commits into
rachfop:mainfrom
AlexAdiaconitei:main

Conversation

@AlexAdiaconitei

Copy link
Copy Markdown
Contributor

Hi again! I've been deploying Docusaurus sites with the new 0.5.0 release and ran into a
few cases where generateMarkdownFiles writes/links a .md file to a path that doesn't
match where Docusaurus actually serves the page — so the link 404s. Here are the fixes I
propose. All three are internal-only (no API changes) and independent, so they can be
reviewed separately.


1. baseUrl baked into the physical file path

Problem. With a non-root baseUrl (e.g. /some/subpath/), the file path is derived
from the absolute doc.url, which already includes baseUrl. Docusaurus writes its own
HTML output without baseUrl (the host mounts it), so the generated .md lands one
level too deep and baseUrl is effectively applied twice.

Solution. Strip the siteUrl baseUrl segment from the pathname before deriving the
physical path.

link in llms.txt:  https://example.com/some/subpath/guides/intro.md   (unchanged)
file on disk:      guides/intro.md   ✅  (was some/subpath/guides/intro.md)

Root baseUrl: '/' is unaffected.


2. Compound number prefixes not fully stripped

Problem. Ordering prefixes were stripped with /^\d+-/ (a single dash only). A
version-like folder such as 03--1.6.X (prefix 03- + name -1.6.X) became -1.6.X
instead of 1.6.X, so route matching missed and the file was written under a
non-existent -1.6.X/ directory.

Solution. Mirror Docusaurus's DefaultNumberPrefixParser (one-or-more [-_.]
separator, and leave version/date-like names intact).

03--1.6.X          → 1.6.X     ✅  (was -1.6.X)
01-intro           → intro     ✅  (unchanged)
7.0-foo            → 7.0-foo   ✅  (version-like, preserved)

3. Explicit frontmatter slug/id overridden by a coincidental route

Problem. resolveDocumentUrl() only checked frontmatter after a filename-tail
suffix match. A slug: "/" root page whose filename tail is intro could suffix-match an
unrelated /some-section/intro route and steal it — leaving the real root page with no
index.md and no llms.txt entry, and bumping the other page to a -2 suffix.

Solution. Check the explicit slug/id (including the slug: "/" root case) before
the filename heuristic, so an authoritative declaration always wins.

docs/intro.md (slug: "/")   → /                    ✅  index.md, linked
docs/some-section/intro.md  → /some-section/intro  ✅  keeps its path (no -2)

Documents without a slug/id are unaffected.


Testing

Added regression tests for each fix (baseUrl, compound prefixes, and the slug/id collision
end-to-end) and ran the full suite with no regressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants