Skip to content
×

What are www subdomains and relative links used for?

A www subdomain determines which hostname a website uses, while relative links determine how URLs are written; the two can be used together and are not mutually exclusive. For example, a main site can use www while its internal links are still written as /Something.html, without hard-coding the hostname. However, if a website spans multiple subdomains, the same relative link may not point to the same destination. Before choosing an approach, clarify the site’s domain structure and check how its links resolve, rather than deciding solely on the basis of SEO rumors.

www is part of domain structure; it does not determine link destinations

The supplied material describes one arrangement: use www for the main site and put resources on a separate resources subdomain. Assigning roles to different hostnames is a separate decision from whether pages use absolute URLs or relative paths.

Multiple subdomains can also add maintenance work. One webmaster described placing some city pages on separate subdomains between 2002 and 2010, while keeping the rest in directories under the main domain. With both structures in use, the testing environment and URL-generation code had to handle exceptions, and relative links in a shared header had to account for the current domain. There were also issues related to JavaScript’s same-origin policy. This is one site’s historical experience, not evidence that subdomains are never worth using.

Relative links make moves easier, but be clear about what they are relative to

The practical benefit of relative links is that they do not require a fixed hostname in every link. The discussion in the supplied material therefore considers them more convenient for local environments, test sites, and moves to another domain or subdomain. However, the different formats still matter:

  • /Something.html: Starts with a slash and is a root-relative link, not an absolute URL.
  • Absolute URL: Explicitly includes the hostname, so its destination does not change with the page’s base href setting.
  • base href: Affects how relative links resolve, including root-relative links. A leading slash alone does not guarantee that the destination hostname will remain unchanged.

Check link destinations when sharing pages across subdomains

If the main site and its subdomains share a navigation bar, do not assume that the same relative path will lead back to the main site everywhere. The city-site example above illustrates why shared files need to handle links in accordance with the domain structure. Relative links avoid hard-coding a hostname, but they also require developers to check the location against which they resolve. For destinations on another domain, absolute URLs can make the target more explicit.

SEO opinions differ, and historical advice is not a current rule

Several answers in the supplied material suggest that the two link formats have no difference in SEO value. Another contributor qualified this by saying that, if a site is accessible through only one domain, there should theoretically be no difference. By contrast, one answer cited advice from Matt Cutts in 2005 favoring absolute links because they were less likely to confuse crawlers. This is historical advice from a specific year. It does not establish that Google currently requires absolute URLs, nor should a personal preference for URL stability be presented as a ranking rule.

www subdomains and relative links: perspectives from across the web

How might using a www subdomain affect resource loading?

One arrangement is to put the main site on www and resources on another subdomain. The supplied material notes that if cookies set for www are not sent to the resource subdomain, this can reduce request overhead and improve performance. However, this depends on cookie settings and site architecture; simply adding www does not guarantee a benefit. This advice applies to full websites whose operators can manage their own domains and resource configuration.

Can absolute URLs prevent website content from being copied?

Absolute URLs should not be treated as a reliable measure against copying. One view in the supplied material is that someone copying a site would need to modify its absolute URLs. Another contributor points out that string replacement is relatively easy, so the deterrent effect may be overstated. Relative links do not necessarily eliminate the need for processing either, especially when a base tag is used: someone copying the site may need to resolve the URLs before replacing them.

How can you write a relative link back to the homepage?

An answer in the supplied material recommends using href="./" to avoid linking to a different homepage URL in that particular case. However, whether this points to the site's homepage depends on the location against which the link resolves and the base setting. You cannot assume that it will lead to the site root from every page. Check its destination on the actual page before using it.

References

  1. Are there any significant disadvantages of forwarding a naked domain to the www. homepage always?webmasters.stackexchange.com — Discusses: How might using a www subdomain affect resource loading?
  2. Absolute vs relative links for search engine crawlers and SEOwebmasters.stackexchange.com — Discusses: Can absolute URLs prevent website content from being copied?
  3. Absolute vs relative links for search engine crawlers and SEOwebmasters.stackexchange.com — Source used in the article above.
  4. Absolute vs relative links for search engine crawlers and SEOwebmasters.stackexchange.com — Source used in the article above.
  5. Displaying "index.php" in URLwebmasters.stackexchange.com — Discusses: How can you write a relative link back to the homepage?
  6. Absolute vs relative links for search engine crawlers and SEOwebmasters.stackexchange.com — Source used in the article above.
  7. Is there such a thing as an "exact match subdomain"?webmasters.stackexchange.com — Source used in the article above.
  8. Absolute vs relative links for search engine crawlers and SEOwebmasters.stackexchange.com — Discusses: Can absolute URLs prevent website content from being copied?; How can you write a relative link back to the homepage?
Keep the conversation going

Join the discussion 0 comments

What are you working through? Share a question or experience and let’s find the next step.

No comments yet. Start the conversation.

Share your thoughts

← Keep exploring
LET’S TALK

Start with your brand.

Tell me about your website and what you want to achieve.

WhatsApp tony@procrustes.info
Scan to chat on WhatsApp