"Home" folder that can handle "/" route. #7891
Replies: 4 comments 5 replies
-
Just create a folder named (home) and put +page.svelte there - done! |
Beta Was this translation helpful? Give feedback.
-
I understand it's possible to do this under the current system, but to me it violates the spirit of the routing system. If "Home" is a discrete page, conceptually the same way that "About" is, you should be able to create a page folder for it. It's convention on the web to serve a site's homepage at the What you're suggesting would confuse a lot of people - because Then if you wanted to set other globals, you'd have to do like It makes sense to be able to set global defaults for your app. That's why we can put files like |
Beta Was this translation helpful? Give feedback.
-
I don't fully understand what you're asking. I'm not saying "no you're wrong!"; I just am not sure I've full understood the complaint, especially the 'conditional' part of it. Can you give a more thorough example? |
Beta Was this translation helpful? Give feedback.
-
Personally, I don't see how the homepage is in any way special wrt routing. src/routes/+page.svelte maps to /. Each subfolder (if we ignore route groups for a second) maps to a sub-segment (like /about, /info, etc.) Likewise: If src/routes/+page.svelte bugs you, why doesn't src/routes/items/+page.svelte? Here are a couple of screenshots: It's pretty clear, that +page.svelte is the root route. Now let's dive into items, which is basically identical structurally: I hope you see the symmetry. I fail to see how the top level +page.svelte is (and should be) in any way different from the one in items. On the contrary, I would find it really confusing. IMHO, The routing system is complex enough as it is. BUT it is consistent - something that couldn't be said if / was treated specially. |
Beta Was this translation helpful? Give feedback.
-
Most SPAs have a "homepage" (sometimes more than one - a marketing one and one for logged in users) but I don't believe the new system accounts for this as a discrete concept. So your homepage ends up being the
+page.svelte
at the root of the/routes/
folder. Then you have to conditionally check if you're on the homepage or not, and it's messy.I would propose the ability to have a page folder just like all the others, but specifically designate it to handle the base "/" route. This would make it easier to keep things organized.
Apologies if there is already a way to do this that I just don't know about.
Beta Was this translation helpful? Give feedback.
All reactions