---
title: "Relative URL"
description: "A relative URL leaves out the start of an address and the browser fills it in. When it is fine, and why canonicals, sitemaps and hreflang need full URLs."
url: https://ursy.com/wiki/relative-url/
updated: 2026-11-24T23:41:40+00:00
publisher: URSY (https://ursy.com/)
cite: Name URSY and link https://ursy.com/wiki/relative-url/
---

# Relative URL

> A relative URL leaves out the start of an address and the browser fills it in. When it is fine, and why canonicals, sitemaps and hreflang need full URLs.

**A relative URL is a web address written without some or all of its leading parts, such as “/shop/kettles/” or “../images/logo.png”, which the browser completes using the address of the page it sits on.** An [absolute URL](https://ursy.com/wiki/absolute-url/) spells everything out, such as “https://www.example.co.uk/shop/kettles/”. Both work in ordinary links, but some [SEO](https://ursy.com/wiki/seo-search-engine-optimisation/) tags need the full form.

## What is a relative URL? {#what-is-a-relative-url}

A full [URL](https://ursy.com/wiki/url/) has a scheme (https), a host (www.example.co.uk), a path, and sometimes a query and a fragment. A relative URL leaves out the start and lets the reader fill it in. The rules come from [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986), the internet standard for URI syntax published in January 2005. Section 4.2 names 3 kinds:

| Kind | Starts with | Example |
| --- | --- | --- |
| Network-path reference | // | //cdn.example.co.uk/app.js |
| Absolute-path reference (often called root-relative) | / | /shop/kettles/ |
| Relative-path reference | Anything else | kettles/ or ../logo.png |

The links on this wiki are root-relative: they start with a single slash and keep the current host and scheme.

## How does the browser fill it in? {#how-does-the-browser-fill-it-in}

It joins the relative part to a base address. RFC 3986 section 5.1 sets the order for finding that base: first a base given inside the content, then one from the wrapping entity, then the address the page was fetched from, then a default. Section 5.4.1 gives worked cases. With a base of http://a/b/c/d;p?q:

- `g` becomes http://a/b/c/g
- `../g` becomes http://a/b/g
- `/g` becomes http://a/g
- `//g` becomes http://g
- `?y` becomes http://a/b/c/d;p?y
- `#s` becomes http://a/b/c/d;p?q#s

In [HTML](https://ursy.com/wiki/html/), a page can set its own base with the base element. MDN’s [reference for the base element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/base) says only 1 is allowed per document, it must come before other elements with URL values, and it also changes links to fragments: with a base of https://example.com/, a link to “#anchor” points to https://example.com/#anchor, not to a spot on the current page.

## Why does it matter for search? {#why-does-it-matter-for-search}

For normal [internal links](https://ursy.com/wiki/internal-linking/), relative and absolute both work, and crawlers resolve them the same way a browser does. The trouble is in the tags that tell [search engines](https://ursy.com/wiki/search-engine/) which address is the “real” one. [Google](https://ursy.com/wiki/google/) is clear on 3 of them:

- **Canonical tags.**  Google’s guide to [consolidating duplicate URLs](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls) says to use absolute paths rather than relative paths with rel=”canonical”. It adds that relative paths are supported but can cause problems in the long run, so it does not recommend them. See [canonical tag](https://ursy.com/wiki/canonical-tag/).
- **Sitemaps.**  Google’s guide to [building a sitemap](https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap) says to use fully-qualified, absolute URLs, because Google will try to crawl them exactly as listed. “/mypage.html” is the wrong form. See [XML sitemap](https://ursy.com/wiki/xml-sitemap/).
- **Hreflang.**  Google’s page on [localised versions](https://developers.google.com/search/docs/specialty/international/localized-versions) says alternate URLs must be fully-qualified, including http or https. It rules out both “//example.com/foo” and “/foo”. See [hreflang](https://ursy.com/wiki/hreflang/).

## Why does it matter for AI answers? {#why-does-it-matter-for-ai-answers}

Your words do not always stay on your page. They get copied into feeds, cached, scraped and chunked for AI systems. A relative link inside text that has been lifted out of the page has lost its base, so “/returns/” may point nowhere, or to the wrong site. Files written for machines, such as [llms.txt](https://ursy.com/wiki/llms-txt/) or a Markdown copy of a page, are safest with full addresses so a reader with no page context can still follow them. The same goes for [syndicated content](https://ursy.com/wiki/content-syndication/) and email newsletters.

## When should you use each? {#when-should-you-use-each}

| Place | Use | Why |
| --- | --- | --- |
| Links in your own page body | Either | Root-relative is short and survives a domain change |
| rel=”canonical” | Absolute | Google’s guidance |
| XML sitemap | Absolute | Google’s guidance |
| Hreflang alternates | Absolute with https | Google’s guidance |
| Feeds, emails, Markdown copies | Absolute | No page around them to supply a base |
| Social sharing tags | Absolute | Read by other sites, not by your page; see [Open Graph](https://ursy.com/wiki/open-graph/) |

## Common mistakes {#common-mistakes}

- **Staging addresses leaking.**  Absolute links typed on a [staging site](https://ursy.com/wiki/staging-site/) still point at it after launch. Root-relative links avoid that.
- **Path-relative links in templates.**  “images/logo.png” works on the home page and breaks 2 folders down. Start shared paths with “/”.
- **A stray base element.**  It quietly changes every relative link, including “#” jump links, and can create [broken links](https://ursy.com/wiki/broken-link/) across a site.
- **Protocol-relative leftovers.**  “//example.com/” was common in the http era. Use https in full; see [HTTPS vs HTTP](https://ursy.com/wiki/https-vs-http/).
- **Relative canonicals on mixed hosts.**  If a page is reachable on www and non-www, a relative canonical inherits whichever host was used, so it fails to consolidate [duplicates](https://ursy.com/wiki/duplicate-content/).
- **Endless folders.**  A wrong relative link on a page whose address keeps changing can spawn ever-deeper paths for crawlers to follow.

## A worked example {#a-worked-example}

A shop page lives at https://www.example.co.uk/shop/kettles/steel/. Here is how 4 links resolve:

| Written | Resolves to |
| --- | --- |
| /delivery/ | https://www.example.co.uk/delivery/ |
| ../glass/ | https://www.example.co.uk/shop/kettles/glass/ |
| reviews/ | https://www.example.co.uk/shop/kettles/steel/reviews/ |
| ?colour=black | https://www.example.co.uk/shop/kettles/steel/?colour=black |

Now the owner adds a base element pointing at the home page. The link “reviews/” suddenly resolves to https://www.example.co.uk/reviews/, which does not exist. One line in the head has broken links on every product page. The last row also shows how a relative link can create a [URL parameter](https://ursy.com/wiki/url-parameter/) version of the page.

## How to check it {#how-to-check-it}

1. Check the canonical is absolute and correct with our [Canonical Checker](https://ursy.com/canonical-checker/).
2. Confirm every sitemap entry is a full https address with our [Sitemap Checker](https://ursy.com/sitemap-checker/).
3. Test hreflang alternates with our [Hreflang Checker](https://ursy.com/hreflang-checker/).
4. Find links that resolve to missing pages with our [Broken Link Checker](https://ursy.com/broken-link-checker/), and follow any that redirect with our [Redirect Checker](https://ursy.com/redirect-checker/).
5. Check social tags use full addresses with our [Open Graph Checker](https://ursy.com/open-graph-checker/).
6. Split any address into its parts with the [URL parser](https://ursy.com/webmaster-tools/url-parser/).
7. Look for ever-growing paths with our [Crawl Trap Checker](https://ursy.com/crawl-trap-checker/).

## Questions {#questions}

### Are relative URLs bad for SEO? {#are-relative-urls-bad-for-seo}

No, not in normal links. Use absolute addresses in canonical tags, sitemaps and hreflang, where Google asks for them.

### Which is better when moving a site? {#which-is-better-when-moving-a-site}

Root-relative body links keep working on a new domain. Canonicals, sitemaps and hreflang must be updated either way. See [moving a website without losing traffic](https://ursy.com/wiki/move-a-website-without-losing-traffic/).

### Does a relative URL change the anchor text value? {#does-a-relative-url-change-the-anchor-text-value}

No. The resolved address and the [anchor text](https://ursy.com/wiki/anchor-text/) are what count, however the link was written.

## Related words {#related-words}

- [URL](https://ursy.com/wiki/url/)
- [Hyperlink](https://ursy.com/wiki/hyperlink/)
- [SEO-friendly URL](https://ursy.com/wiki/seo-friendly-url/)
- [Subdomain](https://ursy.com/wiki/subdomain/)
- [Redirect](https://ursy.com/wiki/redirect/)

## Sources {#sources}

- [RFC 3986: Uniform Resource Identifier (URI), Generic Syntax (January 2005)](https://www.rfc-editor.org/rfc/rfc3986), checked 24 November 2026
- [MDN Web Docs: The Document Base URL element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/base), checked 24 November 2026
- [Google Search Central: How to specify a canonical URL](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls), checked 24 November 2026
- [Google Search Central: Build and submit a sitemap](https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap), checked 24 November 2026
- [Google Search Central: Tell Google about localized versions of your page](https://developers.google.com/search/docs/specialty/international/localized-versions), checked 24 November 2026

*Updated 24 November 2026 by URSY.*
