Search code examples
routessveltesveltekit

Routing in SveltKit


I'm getting a 404 error while trying to access domainname/about/about2 in SvelteKit. Do I have to create a folder for each page I want to add inside the about folder or am I missing something?

My folder structure looks like this:

src/
|-- routes/
    |-- about/
        |-- index.svelte 
        |-- about2.svelte

Solution

  • Your example uses sveltekit's old routing system. With the new routing system, you use +page.svelte to define a page in a route. If you want to continue using the old method of routing, you will have to create an about2 folder and put an index.svelte file in there. Using the new routing method, your project will look like this:

    src/
    |-- routes/
        |-- about/
            |-- +page.svelte 
            |-- about2/
                |-- +page.svelte