Absolute or relative links?

When creating html-based email links, how important is it to use absolute links? Also, What are the benefits of using relative links in general?

+4
source share
7 answers

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

As a minor consideration, Absolute Links do not make you worry about the position of your document relative to other documents, which, although not "difficult" to overcome, adds an extra layer of thought that you should be aware of.

Fortunately, Holy War is not as great as other holy war programming .

For email, absolute links are the only real choice.

+10
source

Email? I do not think there is an option other than absolute links. This ensures that no matter who reads your email and how, your links will point to the right place.

+4
source

For html-based email, absolute links are critical to unlock transactions because they do not have a website context to make relative links work. There are some mechanisms for setting up a BASE document, but try applying this to the lotus notes ...

Personally on websites, I try to use at least root links / foo / yada.htm most of the time, because they are easier to test, and I never use links to parent paths unless I put something on a CD, like would disable them on the web server for security reasons.

I mainly work with CMS / data based sites, so don't be in pain from this manually.

+4
source

I think that when you send html-based mail, you should always use absolute links, remember that mail will be read in the users email client program, and relative links will be useless if you do not specify BASE .

+2
source

absolute links always start from the root website

/portal/images/myImage.png 

relative links always start from the position of this page

 ../images/myImage.png 

it's all about you when you use these approaches because I like to copy / do end-to-end web applications from server to server, and sometimes place them in other subfolders, I prefer to use relative links more than absolute ones.

and in one domain root I always have several subfolders and some default files, for example:

  • /site
  • /portal
  • /post office
  • / iphone
  • default.aspx
  • robots.txt
  • sitemap.xml

and inside everyone who has

  • / Css
  • / Js image
  • files.aspx

instead of having css in the root folder that contains all the CSS files for all supporting applications, for example, I always prefer to have everything in one place, I better move it to another place.

If you tend to create a web application to be persistent in this place, there is no one warm to use absolute paths, it is a matter of taste, not the best practice.

HTML in the letter

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

hope this helps :)

+1
source

I like to use the constant for my top level domain and then add other links to the link. Just in case, if I change my largest domain name, but would like to keep the content / link intact.

For instance:

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

Slightly slower but slightly more flexible.

+1
source

I would agree with balexandre. Although there are advantages to using absolute links, such as fewer features that the search engine confuses, etc., the benefits of using relative links are greater for me because I don’t have to change all the links if I copy the whole parts of the site to another site or even a change in the domain name in the future.

So, for a complex large site with over 8000 pages like mine, I use relative links.

For small sites with less than 50 pages, absolute links are slightly better. (if better at all)

-1
source

All Articles