Internal links, full URL or "truncated" URL?

RTFVerterra's picture

He has: 109 posts

Joined: Dec 2008

I am not sure if "truncated" is the proper term for this. Here goes my question.

Which is correct in terms SEO and best practices? Which one do you use and why?

  1. Full URL, Example:
    <a href="http://www.example.com/folder/file.html">Keyword</a>
  2. Truncated URL, Example:
    <a href="/folder/file.html">Keyword</a>

I heard that no. 1 is a bad idea but I did not get the reasons and no. 2 is not good for feeds especially in img tag.

Your thoughts are greatly appreciated.

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

we use #2 due to the fact that our dev sites are on their own server, and thus require no changing of code when they move to live site.

ie.
LIVE: sitedomain.com
DEV: sitedomain.com.devdomain.com

now in our sites, a constant does get set up to grab the actual domain from the server for times that the full path is needed (mainly only on things that get e-mailed out)

one of the benefits of using method #2 is you could then apply dom scripting to auto open "external links" in a new tab/window by checking the href for beginning with something other that "/"

-Greg

decibel.places's picture

He has: 1,494 posts

Joined: Jun 2008

the proper terms are "absolute url" -- "http://www.example.com/folder/file.html"

and "relative url" -- "/folder/file.html"

(note also that a relative url beginning with a slash is not the same as one without)

The advantage of relative urls is that you can more easily develop a site on one server and move it to another, and the urls will still work

You are correct that relative urls for images do not display in feeds, Drupal has a handy module named Pathologic that converts relative urls to absolute ones.

(Why am I mentioning Drupal? Because I know that RTFVerterra's engineering forum is Drupal)

Greg K wrote:
one of the benefits of using method #2 is you could then apply dom scripting to auto open "external links" in a new tab/window by checking the href for beginning with something other that "/"

Drupal also has a handy extlink module that can add an icon and/or open external links in a new tab/window

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

#2 also lets you move to a new domain more easily, if that ever becomes necessary.

#1 might be a good option in things like blog posts where other sites could be scraping your content. I would only do it if I found that was happening though...

RTFVerterra's picture

He has: 109 posts

Joined: Dec 2008

Thanks everyone, it's clear to me now when to use and when not to use absolute and relative url.

decibel.places wrote:
...proper terms are "absolute url" ... and "relative url"

...RTFVerterra's engineering forum is Drupal...

...Drupal has a handy module named Pathologic...

Thanks for the proper terms and for the Pathologic module, I'll check it out. For now, I need to go to bed, it's almost midnight here. Thanks again. Smiling

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.