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.