Hello routing!

Routes

The code for this page is at ~/src/routes/hello/index.marko. To create a new route, you create a directory under routes/ and put an index.marko in it.

Try creating a template at ~/src/routes/new/index.marko with the following content:

<site-layout>
    <@title>A New Page!</@title>
</site-layout>

Then come back and click this link. 🎉

Parameters

You might have noticed that even though hello/index.marko renders this page, the url is /hello/routing. So what's going on? Parameters!

Take a look at hello/route.js and you'll see it contains exports.path = '/hello/:name'.

Here, :name is an express-style parameter and becomes available as input.params.name within the template! We use this name in the title of the page. Try following one of these links or change the url directly and watch how the title changes:

Scoped Components

Here's another component, but this one is scoped to this page. You see, it lives in ~/src/routes/hello/components/ and therefore is only available to the hello page! 🕶

Elapsed time: 0.0s