Relative URL
A relative URL is a type of web address that points to a page, file, or resource within the same website by using a path relative to the current page’s location, rather than specifying the full domain.
For example, instead of writing https://example.com/blog/post
, a relative URL would simply be /blog/post
.
Relative URLs are commonly used for internal linking, and they help keep your website structure clean, consistent, and easier to manage, especially during development or when migrating domains.
Why relative URLs matter
Relative URLs are useful for:
- Internal site structure — easier to maintain and update
- Domain flexibility — useful if moving from staging to live environments
- Consistent linking — reduces hardcoded absolute URLs that can break
- Avoiding protocol issues — no need to specify HTTP or HTTPS
However, for SEO, absolute URLs are often preferred for canonical tags, sitemaps, and structured data to ensure clarity for search engines.
Relative vs. absolute URLs
Type | Example | Description |
---|---|---|
Relative | /about-us | Assumes the same domain as the current page |
Absolute | https://example.com/about-us | Includes full domain and protocol |
Relative URLs are interpreted based on the current page’s URL, while absolute URLs always point to the same location no matter where they’re used.
HTML example: Relative vs. absolute link
<!-- Relative URL -->
<a href="/contact">Contact Us</a>
<!-- Absolute URL -->
<a href="https://example.com/contact">Contact Us</a>
Both links point to the same page, but the first one is relative — it assumes the domain is already known.
Best practices for using relative URLs
- Use relative URLs for internal links during development or on smaller sites
- Use absolute URLs in canonical tags, sitemaps, and when referencing your content externally
- Ensure relative URLs are correctly structured to avoid broken links
- Be consistent — don’t mix and match too many URL styles
- Use tools like Screaming Frog or Sitebulb to audit your internal linking structure
In summary, a relative URL points to another page on the same website using a simplified path. It’s great for internal navigation and development flexibility, but should be used thoughtfully alongside absolute URLs to support SEO clarity and consistency.