views:

598

answers:

6

When creating links for an an html based email, how critical is it to use absolute links? Also, What are the benefits in using relative links in general?

+8  A: 

Relative links allow you use less code to traverse your structure, and they allow you to move domains without having to do any extra work. You simply copy your directory structure to the new domain, and it works.

As a lesser consideration, Absolute links don't make you worry about the position of your document relative to other documents -- which while not 'hard' to overcome, it adds an extra layer of thought that you have to be cognizant of.

Luckily the Holy War isn't as big as other programming holy wars.

For Email, your only real choice are absolute links.

George Stocker
+3  A: 

Email? I don't think there's an option other than absolute links. This will guarantee you that no matter who and how will read your email, your links will point to the place you need.

+3  A: 

I think when you're sending html based mail, you should always use absolute links, remember that the mail is going to be read in the email client program of the users, and the relative links will be useless unless you specify a BASE tag.

CMS
when sending mailing, BASE target tag is CSS and that is not understood for some current mail readers!a CSS support in email clients > http://www.campaignmonitor.com/css/
balexandre
+2  A: 

absolute links always start from the root website

/portal/images/myImage.png

relative links always start from the position of that page

../images/myImage.png

it is all about you when using this approaches, because I like to copy/past the hole web applications from server to server and sometimes place it in other sub folders, I tend to use Relative links more than absolute.

and in one domain root I always have several subfolders and some default files like:

  • /webSite
  • /portal
  • /mail
  • /iphone
  • default.aspx
  • robots.txt
  • sitemap.xml

and inside everyone I have

  • /css
  • /js
  • /images
  • files.aspx

instead of having a css in the root folder that contains all CSS files for all the sub applications for example, I always prefer to have all in just one place, it is better for me to move it somewhere else.

if you tend to build a web app to be permanent in that place, there is no warm to use absolute paths, it is a matter of taste and not best practice.

HTML in the email

This is the place that you need to have the complete path http://www.mydomin.com/images/myImage.png

hope it helps :)

balexandre
thanks for the info!!!
rashneon
+2  A: 

For an html based email, absolute links are deal breaker critical, because they don't have the context of a web site to make relative links work. There are some mechanisms for setting the BASE of a document, but try feeding that to lotus notes...

Personally, on web sites, I try to use at least root absolute links /foo/yada.htm most of the time, because they are easier to test, and I never use parent path links unless putting something on a CD, like to have them turned off on the web server for security reasons.

I work mainly with CMS/data driven sites, so don't have the pain of doing it by hand.

seanb
+2  A: 

I like to use a constant for my top level domain, and then add on other parts to the link. This is just in case I change my top most domain name, but would like to keep the content/link intact.

For example:

COMPLETE_SITE_NAME = "http://www.mysite.com/"; link = COMPLETE_SITE_NAME . "pagetoContent.html";

Slightly slower, but a little bit more flexible.

barfoon