Skip to main content

To create routes with dynamic parameters, use square brackets around a valid variable name. For example, a file like src/routes/blog/[slug]/+page.svelte will create a route that matches /blog/one, /blog/two, /blog/three and so on.

Let’s create that file:

src/routes/blog/[slug]/+page
<h1>blog post</h1>

We can now navigate from the /blog page to individual blog posts. In the next chapter, we’ll see how to load their content.

Multiple route parameters can appear within one URL segment, as long as they are separated by at least one static character: foo/[bar]x[baz] is a valid route where [bar] and [baz] are dynamic parameters.

Edit this page on GitHub

previous next
1
2
<p>home</p>