{
    "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/",
    "canonical": "https://ursy.com/wiki/relative-url/",
    "markdown": "https://ursy.com/wiki/relative-url/index.md",
    "json": "https://ursy.com/wiki/relative-url/index.json",
    "published": "2026-11-24T23:41:40+00:00",
    "updated": "2026-11-24T23:41:40+00:00",
    "language": "en-GB",
    "publisher": {
        "name": "URSY",
        "url": "https://ursy.com/"
    },
    "cite": "Name URSY and link https://ursy.com/wiki/relative-url/",
    "headings": [
        {
            "level": 2,
            "text": "What is a relative URL?",
            "id": "what-is-a-relative-url",
            "url": "https://ursy.com/wiki/relative-url/#what-is-a-relative-url"
        },
        {
            "level": 2,
            "text": "How does the browser fill it in?",
            "id": "how-does-the-browser-fill-it-in",
            "url": "https://ursy.com/wiki/relative-url/#how-does-the-browser-fill-it-in"
        },
        {
            "level": 2,
            "text": "Why does it matter for search?",
            "id": "why-does-it-matter-for-search",
            "url": "https://ursy.com/wiki/relative-url/#why-does-it-matter-for-search"
        },
        {
            "level": 2,
            "text": "Why does it matter for AI answers?",
            "id": "why-does-it-matter-for-ai-answers",
            "url": "https://ursy.com/wiki/relative-url/#why-does-it-matter-for-ai-answers"
        },
        {
            "level": 2,
            "text": "When should you use each?",
            "id": "when-should-you-use-each",
            "url": "https://ursy.com/wiki/relative-url/#when-should-you-use-each"
        },
        {
            "level": 2,
            "text": "Common mistakes",
            "id": "common-mistakes",
            "url": "https://ursy.com/wiki/relative-url/#common-mistakes"
        },
        {
            "level": 2,
            "text": "A worked example",
            "id": "a-worked-example",
            "url": "https://ursy.com/wiki/relative-url/#a-worked-example"
        },
        {
            "level": 2,
            "text": "How to check it",
            "id": "how-to-check-it",
            "url": "https://ursy.com/wiki/relative-url/#how-to-check-it"
        },
        {
            "level": 2,
            "text": "Questions",
            "id": "questions",
            "url": "https://ursy.com/wiki/relative-url/#questions"
        },
        {
            "level": 3,
            "text": "Are relative URLs bad for SEO?",
            "id": "are-relative-urls-bad-for-seo",
            "url": "https://ursy.com/wiki/relative-url/#are-relative-urls-bad-for-seo"
        },
        {
            "level": 3,
            "text": "Which is better when moving a site?",
            "id": "which-is-better-when-moving-a-site",
            "url": "https://ursy.com/wiki/relative-url/#which-is-better-when-moving-a-site"
        },
        {
            "level": 3,
            "text": "Does a relative URL change the anchor text value?",
            "id": "does-a-relative-url-change-the-anchor-text-value",
            "url": "https://ursy.com/wiki/relative-url/#does-a-relative-url-change-the-anchor-text-value"
        },
        {
            "level": 2,
            "text": "Related words",
            "id": "related-words",
            "url": "https://ursy.com/wiki/relative-url/#related-words"
        },
        {
            "level": 2,
            "text": "Sources",
            "id": "sources",
            "url": "https://ursy.com/wiki/relative-url/#sources"
        }
    ],
    "links": [
        {
            "text": "absolute URL",
            "url": "https://ursy.com/wiki/absolute-url/",
            "internal": true
        },
        {
            "text": "SEO",
            "url": "https://ursy.com/wiki/seo-search-engine-optimisation/",
            "internal": true
        },
        {
            "text": "URL",
            "url": "https://ursy.com/wiki/url/",
            "internal": true
        },
        {
            "text": "RFC 3986",
            "url": "https://www.rfc-editor.org/rfc/rfc3986",
            "internal": false
        },
        {
            "text": "HTML",
            "url": "https://ursy.com/wiki/html/",
            "internal": true
        },
        {
            "text": "reference for the base element",
            "url": "https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/base",
            "internal": false
        },
        {
            "text": "internal links",
            "url": "https://ursy.com/wiki/internal-linking/",
            "internal": true
        },
        {
            "text": "search engines",
            "url": "https://ursy.com/wiki/search-engine/",
            "internal": true
        },
        {
            "text": "Google",
            "url": "https://ursy.com/wiki/google/",
            "internal": true
        },
        {
            "text": "consolidating duplicate URLs",
            "url": "https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls",
            "internal": false
        },
        {
            "text": "canonical tag",
            "url": "https://ursy.com/wiki/canonical-tag/",
            "internal": true
        },
        {
            "text": "building a sitemap",
            "url": "https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap",
            "internal": false
        },
        {
            "text": "XML sitemap",
            "url": "https://ursy.com/wiki/xml-sitemap/",
            "internal": true
        },
        {
            "text": "localised versions",
            "url": "https://developers.google.com/search/docs/specialty/international/localized-versions",
            "internal": false
        },
        {
            "text": "hreflang",
            "url": "https://ursy.com/wiki/hreflang/",
            "internal": true
        },
        {
            "text": "llms.txt",
            "url": "https://ursy.com/wiki/llms-txt/",
            "internal": true
        },
        {
            "text": "syndicated content",
            "url": "https://ursy.com/wiki/content-syndication/",
            "internal": true
        },
        {
            "text": "Open Graph",
            "url": "https://ursy.com/wiki/open-graph/",
            "internal": true
        },
        {
            "text": "staging site",
            "url": "https://ursy.com/wiki/staging-site/",
            "internal": true
        },
        {
            "text": "broken links",
            "url": "https://ursy.com/wiki/broken-link/",
            "internal": true
        },
        {
            "text": "HTTPS vs HTTP",
            "url": "https://ursy.com/wiki/https-vs-http/",
            "internal": true
        },
        {
            "text": "duplicates",
            "url": "https://ursy.com/wiki/duplicate-content/",
            "internal": true
        },
        {
            "text": "URL parameter",
            "url": "https://ursy.com/wiki/url-parameter/",
            "internal": true
        },
        {
            "text": "Canonical Checker",
            "url": "https://ursy.com/canonical-checker/",
            "internal": true
        },
        {
            "text": "Sitemap Checker",
            "url": "https://ursy.com/sitemap-checker/",
            "internal": true
        },
        {
            "text": "Hreflang Checker",
            "url": "https://ursy.com/hreflang-checker/",
            "internal": true
        },
        {
            "text": "Broken Link Checker",
            "url": "https://ursy.com/broken-link-checker/",
            "internal": true
        },
        {
            "text": "Redirect Checker",
            "url": "https://ursy.com/redirect-checker/",
            "internal": true
        },
        {
            "text": "Open Graph Checker",
            "url": "https://ursy.com/open-graph-checker/",
            "internal": true
        },
        {
            "text": "URL parser",
            "url": "https://ursy.com/webmaster-tools/url-parser/",
            "internal": true
        },
        {
            "text": "Crawl Trap Checker",
            "url": "https://ursy.com/crawl-trap-checker/",
            "internal": true
        },
        {
            "text": "moving a website without losing traffic",
            "url": "https://ursy.com/wiki/move-a-website-without-losing-traffic/",
            "internal": true
        },
        {
            "text": "anchor text",
            "url": "https://ursy.com/wiki/anchor-text/",
            "internal": true
        },
        {
            "text": "Hyperlink",
            "url": "https://ursy.com/wiki/hyperlink/",
            "internal": true
        },
        {
            "text": "SEO-friendly URL",
            "url": "https://ursy.com/wiki/seo-friendly-url/",
            "internal": true
        },
        {
            "text": "Subdomain",
            "url": "https://ursy.com/wiki/subdomain/",
            "internal": true
        },
        {
            "text": "Redirect",
            "url": "https://ursy.com/wiki/redirect/",
            "internal": true
        }
    ],
    "words": 1147,
    "text": "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 spells everything out, such as “https://www.example.co.uk/shop/kettles/”. Both work in ordinary links, but some SEO tags need the full form. What is a relative URL? A full 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, 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? 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, a page can set its own base with the base element. MDN’s reference for the base element 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? For normal internal links, 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 which address is the “real” one. Google is clear on 3 of them: Canonical tags. Google’s guide to consolidating 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. Sitemaps. Google’s guide to building a 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. Hreflang. Google’s page on localised versions says alternate URLs must be fully-qualified, including http or https. It rules out both “//example.com/foo” and “/foo”. See hreflang. 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 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 and email newsletters. 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 Common mistakes Staging addresses leaking. Absolute links typed on a 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 across a site. Protocol-relative leftovers. “//example.com/” was common in the http era. Use https in full; see 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. 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 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 version of the page. How to check it Check the canonical is absolute and correct with our Canonical Checker. Confirm every sitemap entry is a full https address with our Sitemap Checker. Test hreflang alternates with our Hreflang Checker. Find links that resolve to missing pages with our Broken Link Checker, and follow any that redirect with our Redirect Checker. Check social tags use full addresses with our Open Graph Checker. Split any address into its parts with the URL parser. Look for ever-growing paths with our Crawl Trap Checker. Questions 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? 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. Does a relative URL change the anchor text value? No. The resolved address and the anchor text are what count, however the link was written. Related words URL Hyperlink SEO-friendly URL Subdomain Redirect Sources RFC 3986: Uniform Resource Identifier (URI), Generic Syntax (January 2005), checked 24 November 2026 MDN Web Docs: The Document Base URL element, checked 24 November 2026 Google Search Central: How to specify a canonical URL, checked 24 November 2026 Google Search Central: Build and submit a sitemap, checked 24 November 2026 Google Search Central: Tell Google about localized versions of your page, checked 24 November 2026 Updated 24 November 2026 by URSY.",
    "source": "https://ursy.com/wiki/relative-url/"
}