Linking to other pages

Links can be created to other pages in two ways:

  • relative links
  • absolute links

When linking to other pages, always use the name of the other page as the URL, without the file extension.

To create a relative link, start the link with a . (period). For the following folder structure:

...
└── foo
    β”œβ”€β”€ bar
    β”‚   β”œβ”€β”€ baz
    β”‚   β”‚   β”œβ”€β”€ corge/+page.md
    β”‚   β”‚   β”œβ”€β”€ quux/+page.md
    β”‚   β”‚   └── +page.md
    β”‚   β”œβ”€β”€ grault/+page.md
    β”‚   └── +page.md
    β”œβ”€β”€ waldo/+page.md
    └── +page.md

if we were writing documentation in baz.md, we could link to other pages in the following way:

- [link to corge](./corge)        <= same folder
- [link to bar](../)              <= one folder up
- [link to grault](../grault)     <= one folder up
- [link to foo](../../)           <= two folders up
- [link to waldo](../../waldo)    <= two folders up

To create an absolute link, start the link with a /, and treat the src/routes/ folder as the lowest folder level. For the following folder structure:

src
└── routes
    β”œβ”€β”€ foo
    β”‚   └── bar
    β”‚       β”œβ”€β”€ baz/+page.md
    β”‚       └── +page.md
    β”œβ”€β”€ quux
    β”‚   β”œβ”€β”€ waldo/+page.md
    β”‚   └── +page.md
    └── +page.md

to link to waldo/+page.md from baz/+page.md:

- [link to waldo](/quux/waldo)

This can make for more portable documents when referencing pages that are not in the same folder as the page you’re currently working on.