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.
Relative links to other pages
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
Absolute links to other pages
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.