Menu

Should internal links be relative or absolute? Let's argue about it
πŸ“°

Should internal links be relative or absolute? Let's argue about it

DEV Community: htmlΒ·linkbruno.comΒ·8 days ago
#p8Sfwt2e
#devto2#devto#dev#anchor#links
Long article (1062 words) β€” no AI summary yet.
Reading 0:00
15s threshold

Scheduled broken-link and redirect checks that tell you the moment a link breaks β€” linkbruno.com

There are three ways to link from one page on your site to another:

<a href = "https://www.example.com/docs/install/" > <!-- absolute --> <a href = "/docs/install/" > <!-- root-relative --> <a href = "../install/" > <!-- relative -->

Enter fullscreen mode

Exit fullscreen mode

All three can point at the same page. They break in completely different situations. And teams argue about this more than you'd think, usually right after a migration in which one of them caused a few thousand broken links.

So which should you use? Let's argue about it.

The case for absolute URLs

They mean the same thing everywhere. An absolute URL doesn't depend on where the page lives, what the <base> tag says, or how the reader got to it. Copy a paragraph into an email, a feed reader, a newsletter or a Slack message, and the link still works.

RSS and syndication need them.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.