Improved support for serving Starlight docs from a custom subpath #966
Replies: 17 comments 4 replies
-
For a quick and hacky solution you can nest the |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick solution. Seems to work alright, although I can't find a way to update the nav link in the header. It still points to the root url. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately configuring the starlight({
head: [
{
tag: 'script',
content: `window.addEventListener('load', () => document.querySelector('.site-title').href += 'docs/')`,
},
],
}); |
Beta Was this translation helpful? Give feedback.
-
Thanks for the workaround. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the issue @mirrorleap! As @BryceRussell said, this workaround is available today and I just wrote some docs for this approach, but we would like to improve support here in the future. I think most likely would be something like a // astro.config.mjs
defineConfig({
integrations: [
starlight({
title: 'Docs at a subpath',
base: 'guides',
}),
],
}); This would prefix all Starlight routes with There are some questions around this still to answer:
|
Beta Was this translation helpful? Give feedback.
-
It's a must have for me :) Suggestion to add more powerful customization:
|
Beta Was this translation helpful? Give feedback.
-
Hey @jagu-sayan! As noted above this is already supported, we’d just like to improve the DX around it. Thanks for sharing your other ideas — things in this direction are all stuff on our radar 🙌 |
Beta Was this translation helpful? Give feedback.
-
Hi @delucis, thanks for your response. I agree with your approach to have the
Here are my suggestions:
|
Beta Was this translation helpful? Give feedback.
-
Hosts like Netlify, Vercel, and GitHub Pages have a very simple default behaviour where they look for a That said, if a user’s project already creates a root-level 404, then Starlight’s shouldn’t overwrite it. |
Beta Was this translation helpful? Give feedback.
-
Making a note that it might not be super clear what happens to Which of these should the pattern be?
Usually language tags are the first segment in a URL path, but not sure if that’s what everyone looking for This wouldn’t impact |
Beta Was this translation helpful? Give feedback.
-
Just came across an issue with starlight being incompatible with a custom 404 page. A base URL option would be great as I don't want to expose the documentation whenever a user enters a wrong URL in general. |
Beta Was this translation helpful? Give feedback.
-
@delucis as we have discussed in Discord, would like to get this issue! I have a branch as you can see in the historic of the issue. I figured out how to add baseUrl at the configs, but not the right entry point to make it work! |
Beta Was this translation helpful? Give feedback.
-
I'd personally put the language before the base path, but imho it should be a selectable option. If you have a monolingual site, with multi-lingual docs, then after the base path makes sense, if everything is multilingual having the language path moved in the middle of the path makes no sense. |
Beta Was this translation helpful? Give feedback.
-
If there's multiple starlight sites in the same origin, should theme selection also be separated? Currently starlight is using hardcoded Example of separated theme selection implemented in mkdocs-material, they are prepending the base path to the key. Excerpt of formatted source of __md_scope=new URL(".",location)
__md_get=(e, _=localStorage, t=__md_scope) => JSON.parse(_.getItem(t.pathname+"."+e)) Excerpt of formatted source of __md_scope=new URL("..",location) Excerpt of formatted source of __md_scope=new URL("../../../../..",location) |
Beta Was this translation helpful? Give feedback.
-
It appears that the below code: was added after most of the conversation in this thread, which takes into consideration the |
Beta Was this translation helpful? Give feedback.
-
What version of
starlight
are you using?0.5.2
What is your idea?
Starlight integration helps to easily build documentation with Astro. However, by default, it converts the entire Astro site into a documentation site. It will be a useful feature if Starlight docs can be served from a custom path.
Why is this feature necessary?
Astro has a unique feature that allows for multiple integrations including UI frameworks and other functionality. Starlight is one of those exciting integrations.
Allowing Starlight docs to be served from a sub/custom path, will have the following benefits:
Do you have examples of this feature in other projects?
Example -
Route(s) for Astro site content:
Route(s) For Starlight docs within Astro site:
Participation
Beta Was this translation helpful? Give feedback.
All reactions