Absolute Links vs Relative Links: Which to Use for SEO
An absolute link spells out the whole URL; a relative link leaves the browser to fill in the rest. Here is where search engines require the absolute form, where either works, and how to audit a repo for the mistakes.

On this page
- TL;DR
- Absolute links, relative links, and root-relative links
- Do absolute links matter for SEO?
- Where SEO requires absolute URLs
- How to choose, file by file
- How to audit links in a repo
- Absolute links FAQ
- What is an absolute link?
- Are absolute links better for SEO than relative links?
- Do relative links protect against content scraping?
- What is a root-relative link?
- Should I convert all my internal links to absolute URLs?
- References
TL;DR
- An absolute link contains the full address: protocol, domain and path (
https://example.com/blog/post). - A relative link contains only part of it (
/blog/postor../post); the browser resolves the rest from the current page. - For ordinary internal
<a href>links, Google handles both. Pick one style and stay consistent. - Some places must be absolute:
rel="canonical"(Google recommends it), XML sitemaps,hreflangalternates, and Open Graph image URLs. - The real SEO risks are hard-coded staging or
http://domains, and relative paths that resolve somewhere you did not expect.
An absolute link is a hyperlink whose href contains the complete URL of its destination, including the protocol (https://) and the domain. It points to the same place no matter which page, domain or environment it appears on. A relative link leaves part of the address out and depends on the page it sits on to fill the gap.
Absolute links, relative links, and root-relative links
There are three forms you will meet in real code:
| Form | Example href |
Resolves against |
|---|---|---|
| Absolute | https://example.com/pricing |
Nothing; it is complete |
| Root-relative | /pricing |
The current page's protocol and domain |
| Document-relative | pricing or ../pricing |
The current page's full path |
A fourth form, the protocol-relative URL (//example.com/pricing), inherits only the scheme. It was a workaround from the mixed HTTP/HTTPS era; on an all-HTTPS site, write https:// explicitly.
Root-relative links are what most frameworks produce. A Next.js <Link href="/pricing">, an Astro <a href="/pricing"> and a Markdown [pricing](/pricing) all render root-relative hrefs. Document-relative links are the fragile kind: ../pricing means something different on /blog/post than on /blog/post/ (trailing slash), and the difference only shows up after deploy.
Do absolute links matter for SEO?
For regular internal links, not much. Google resolves relative URLs against the page they appear on, so /pricing and https://example.com/pricing reach the same page and pass the same signals. Google's guidance on crawlable links asks for an <a> element with an href; it accepts both forms.
What matters is that the link resolves to the canonical URL in one hop. These are the internal-link problems that cost crawl budget and dilute signals, and the URL form is often the cause:
- Hard-coded old origins.
http://example.com/...orhttps://www.example.com/...written into a template when the live site ishttps://example.com. Every click and every crawl takes a redirect. - Staging leaks. An absolute link to
https://staging.example.comor a preview URL copied from a browser bar into content. Relative links cannot leak an environment; absolute ones can. - Trailing-slash drift. Document-relative paths resolving to a different directory when the page URL gains or loses a trailing slash.
A sensible default: root-relative for internal links in content and components, absolute where a spec or a crawler outside the page needs the full URL. That second list is short and strict.
Where SEO requires absolute URLs
These are not style choices. Each one is documented by the consumer that reads the URL.
- Canonical tags. Google's duplicate-URL documentation says to "use absolute paths rather than relative paths with the
rel="canonical"link element" (Google: consolidate duplicate URLs). A relative canonical rendered on a staging host points at staging. - XML sitemaps. Google asks for "fully-qualified, absolute URLs" in sitemaps (Google: build a sitemap). A sitemap is read with no page context, so there is nothing to resolve a relative path against. Our Next.js sitemap guide shows how to keep the origin in one constant.
- hreflang alternates. "Alternate URLs must be fully-qualified, including the transport method" (Google: localized versions).
- Open Graph and Twitter card images. Social scrapers fetch
og:imageout of context; a relative path gives them nothing to fetch. In Next.js, settingmetadataBaseonce in the root layout makes the framework emit absolute URLs for relative metadata values. - Anything that leaves the site. RSS feeds, emails,
llms.txt, and JSON-LDurl/@idfields are read without your page around them. Write them absolute.
How to choose, file by file
| Where the URL lives | Use | Why |
|---|---|---|
| Links in Markdown content | Root-relative | Survives domain moves and preview deploys |
| Nav, footer, component links | Root-relative (framework Link) |
Same, plus client-side routing |
<link rel="canonical"> |
Absolute | Google recommendation |
sitemap.xml <loc> |
Absolute | Required by Google and the sitemap protocol |
hreflang alternates |
Absolute | Required by Google |
og:image, twitter:image |
Absolute (via one base URL) | Fetched without page context |
JSON-LD url, @id, image |
Absolute | Read as standalone data |
| Links to other domains | Absolute | There is no other option |
The pattern underneath: build every absolute URL from one site-origin constant (an env var or a config value) and never type the domain into a template. That one rule removes the staging leak, the http:// leftover and the www mismatch at once.
How to audit links in a repo
If your site lives in a repository, the audit is a search, not a crawl.
- Find hard-coded origins. Search source and content for your own domain in hrefs:
grep -rn "href=\"https\?://\(www\.\)\?example.com" src content. Each hit is a candidate for a root-relative path or the origin constant. - Find wrong origins. Search for
http://,staging.,localhost,vercel.appand your preview domain inside hrefs and metadata. - Find document-relative paths. Search for
href="../and hrefs that do not start with/,#,mailto:or a scheme. Replace them with root-relative paths. - Check the rendered head. Build and fetch a page, then confirm the canonical,
og:imageandhreflangvalues print with the production origin. - Check the sitemap output, not the generator code: every
<loc>should begin withhttps://and your canonical host.
SEOAgent runs this kind of check from inside your coding agent: its technical SEO and internal linking checks read the files in your repo, and every fix lands as a diff you approve before it ships. For the URL itself, see what an SEO slug is; for the rest of the head tags, see the Next.js SEO guide.
Absolute links FAQ
What is an absolute link?
An absolute link is a hyperlink with the complete URL in its href: protocol, domain and path, such as https://example.com/about. It points to the same address from any page.
Are absolute links better for SEO than relative links?
Not for ordinary internal links; Google resolves both to the same URL. Absolute URLs are required or recommended in canonical tags, sitemaps, hreflang and social image tags, where the URL is read without page context.
Do relative links protect against content scraping?
Barely. A scraper that copies your HTML gets relative links that break on its domain, which removes your links but also the attribution. A self-referencing absolute canonical tag is the more useful signal, because it tells search engines which copy is the original.
What is a root-relative link?
A root-relative link starts with a slash, such as /pricing. The browser adds the current protocol and domain. It is the default form most frameworks produce for internal links.
Should I convert all my internal links to absolute URLs?
No. Bulk-converting internal links adds a hard-coded domain to every file and makes domain or HTTPS migrations harder. Keep internal links root-relative and generate absolute URLs from one origin setting where a spec requires them.
References
Put SEO on autopilot in your own editor
SEOAgent runs as a free skill inside Claude Code, Cursor, and Codex — on the model you already pay for. Audit, plan, and write SEO content right in your repo, with every change reviewed before it ships. No second AI subscription.
What do you use to work on your site?
Pick one above and we take you to the right setup.