Nodea — logo

Relative link

A relative link is a hyperlink that describes a resource's location relative to the address of the page currently being viewed, without specifying the protocol or domain. Instead of a full URL it contains only a path — for example ../contact or /pricing — which the browser resolves against the current location.

How a relative link works

When a browser meets a relative link, it resolves it by combining the given path with the base address of the current page. There are two main kinds of relative path. A document-relative path (such as page.html or ../image.png) is resolved against the directory of the current page and traverses the folder structure. A root-relative path, beginning with a slash (such as /blog/article), is always measured from the domain root, no matter where the current page lives. This is the essential contrast with an absolute link, which spells out the complete address.

Practical application

Relative links dominate a site's internal linking because they simplify the HTML and make a website easy to move between environments. The same page behaves identically on a development server, in staging and in production, since the links carry no hard-coded domain — there is no mass find-and-replace after migrating to a new host or a new domain.

There is a caveat, though: a relative link automatically inherits the protocol and domain variant of the current address, so if a site is reachable at several addresses it can encourage duplicate URLs. That is why anything parsed outside the page context — XML sitemaps, RSS feeds, canonical tags — consistently uses absolute links, while relative links are reserved for internal navigation.

Powiązane pojęcia

Najczęstsze pytania

Do relative links affect SEO?

On their own they are neutral for rankings, as long as the server resolves them correctly. Problems arise when the same content is reachable at several addresses (www and non-www, HTTP and HTTPS) and relative links inherit whichever variant the current URL uses, which can cause duplication. That is why canonical tags and sitemaps always use absolute links.