You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sidebar links with a hash or query string get a trailing slash or .html appended after the hash #4286
A manual sidebar link that contains a hash or a query string is formatted as if the whole string were a pathname. The trailing slash or .html extension is added to the end of the string, which puts it inside the fragment or query value.
renders href="/guides/components/#tabs/". The browser looks for an element with id tabs/, so the link does not scroll to the section.
With build.format: 'file', the same link renders href="/guides/components/#tabs.html", which points at the directory URL and the wrong fragment.
Other examples from createPathFormatter():
options
input
output
directory, always
/guides/components#tabs
/guides/components#tabs/
directory, always
/search?q=astro
/search?q=astro/
directory, never
/guides/components/#tabs
/guides/components/#tabs (slash kept)
file, ignore
/search?q=astro
/search?q=astro.html
file, ignore
/#_top
/#_top.html
What should happen
Only the pathname should be formatted, and the query string and hash should be kept as is. For example /guides/components#tabs with trailingSlash: 'always' should become /guides/components/#tabs, and /search?q=astro with build.format: 'file' should become /search.html?q=astro.
formatPath() in packages/starlight/src/utils/createPathFormatter.ts passes the full href to ensureTrailingSlash(), stripTrailingSlash() and ensureHtmlExtension(). These helpers only look at the end of the string, so any ?query or #hash suffix ends up before the added slash or extension. makeSidebarLink() in navigation.ts runs every non absolute sidebar link through formatPath().
Activity