Starlight missing trailing slash
Starlight's sidebar doesn't include a trailing slash ("/") at the end of the URL, leading to a 301 redirect to the page. It is a minor thing, but SEO-wise it is not great. I tried to look it up online but couldn't find any solution ๐ฆ
33 Replies
Hi @Ricardo Batista. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not contain specific information on how to add a trailing slash to URLs in Starlight's sidebar. However, there are discussions about handling trailing slashes in Wasp and its associated projects. For instance, in Wasp, a script was added to remove any redundant trailing slashes from the end of the URL to fix a similar issue source (https://github.com/wasp-lang/wasp/issues/297).
For your specific issue with Starlight, I would recommend reaching out to the Starlight or Astro community for more targeted advice.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Ricardo Batista, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
Hmm that's interesting! Do you have experience with Astro in general and maybe some advice for us? ๐ We'll have to research this a bit to see what we can do
To be honest, a little experience with Astro, but not particularly with Starlight. I have attached proof of what I am saying: the URL bar shows the trailing slash, but if you hover over the sidebar link it doesn't have (see bottom of the page).
Discord
Discord - A New Way to Chat with Friends & Communities
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Great! I'll keep track there as well ๐
Discord
Discord - A New Way to Chat with Friends & Communities
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
@miho point solved here: https://discord.com/channels/830184174198718474/1232933525049704510/1233786499800109136
Wohooo @Ricardo Batista, you just became a Waspeteer level 3!
Do you think there is a risk of conflicts/dependencies if I upgrade them?
I think it's perfectly fine if you upgrade them, but make sure to check out the migration guide of the Astro team ๐
But this means we have to upgrade Astro in Open SaaS as well, I'll create a Github issue ๐
Thank you for investigating this and helping others!
I'm not sure if you are up for upgrading it in the Open SaaS repo? ๐ https://github.com/wasp-lang/open-saas/issues/111
GitHub
Upgrade Astro and Starlight versions ยท Issue #111 ยท wasp-lang/open-...
Reported by user: Starlight's sidebar doesn't include a trailing slash ("/") at the end of the URL, leading to a 301 redirect to the page. It is a minor thing, but SEO-wise it is ...
Hey @miho happy to help!
I have taken so much value out of your work that the minimum is to pay it back in making it better.
What do you mean? Want me to try upgrading it myself in my repo and report back?
That would be amazing! It would help us to know what to do with Open Saas and how to upgrade it more easily ๐
My first try at it @miho:
@miho let me know what you think
Wohooo @Ricardo Batista, you just became a Waspeteer level 4!
Oh, it would require you to upgrade
astro
as well to version 5 it seems. I'd recommend the following battle plan:
- try creating a new Starlight project npm create astro@latest -- --template starlight
and then see how that differs from what you have in Open SaaS
- upgrade the deps to those in the new project and see if you have any issues
- update any other config files to match
Let me know if this makes sense to you ๐ if you get stuck we can debug again together@miho sorry, had some busy days.
Let me walk you through what I did:
1. Run
npx @astrojs/upgrade
in the /blog folder, all dependencies updated in the package*.json files
2. When I run npm run dev
I get:
2.1. Warnings:
2.2. [object Object] in title (see image attached)
2.3 When I click /blog, I get the error: Cannot read properties of undefined (reading 'skipLink.label')
So indeed this migration needs to be probably checked.
When I do a clean installation, I didn't see any fundamental change in astro.config.mjs. I am not expert enough to be changing more than this, so maybe have your help first.Ok, let me try upgrading myself and I'll comment what happens ๐
Thanks @miho , do you have any news so far?
I'll try this today, I'll report back ๐
Any news @miho ?
This is what worked for me, here's a PR that we still didn't merge, but you can get inspired https://github.com/wasp-lang/open-saas/pull/122
GitHub
Updates Astro, Starlight, Starlight Blog versions by infomiho ยท Pul...
Updates Astro to v4
Updates Starlight to latest version
Updates Starlight Blog to latest version
This was mostly done now due to users having SEO issues with trailing slashes in the blog URLs.
Thanks @miho !
I just updated my code with those changes, but couldn't see the trailing slash issue fixed. Did you see yours working?
@miho it seems like it was identified by the Astro Starlight team as an issue to be created: https://discord.com/channels/830184174198718474/1232933525049704510/1238992881469882399
Thank you for tracking down the bug ๐
@miho the solution is simple (see here), might be worth adding this to newest versions:
- updating Astro and Starlight (there is already a PR for this)
- adding
trailingSlash: 'always'
- updating src/components/MyHeader.astro
with <a href="/blog/">
@miho do you have the capacity to take this one on, or should somebody else take it over?
@martinsos please let's transfer it to someone else ๐
@Vinny (@Wasp) you probably know the most about this, maybe you could take it over?
ok let me get up to speed on this real quick
ok nice. I merged Miho's PR but i'll make this changes ASAP
Is this an issue that's specific to you @Ricardo Batista , or do you think all users would benefit from these changes?
so it always causes a 301 redirect at the moment?
hmm.. if I try it out on https://docs.opensaas.sh I don't see a 301 redirect
in fact, it always includes a trailing slash
ahh ok I see it now under blog. whoops
All users will benefit from this, as it is causing a redirect right now. It's only on the blog, yes.
yep. now i get it. Nice catch! Updating it now ๐
btw @Ricardo Batista I removed the duplicate
Blog
link in the nav bar that comes with the new Astro updates. Check out the custom component here if you haven't gotten around to fixing it yourself yet ๐Well spotted, hadn't noticed it ๐