Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Links and Stucture

Featured Replies

Firstly, hello to everyone as I have just joined this forum. I hope Tuesday is shaping up to be as wierd as mine. :p hehe.

 

Anyway my first post is about a particular subject that I am confumbled about. I always strive to conform to web standards and keep my sites as neat and tidy as they can be. One particular item I see a lot of is relates to the way in which links are coded.

 

I would always code a link as follows:

 

<a href="about.html">About</a>

 

or if it was sub directory

 

<a href="about/about.html">About us</a>

 

However, what I am seeing more and more of is links written like this:

 

<a href="/about/">About</a>

 

Alternatively

 

<a href="/about/team/">The Team</a>

 

I want to know how this version of linking works and what structure my web directories should take. Any help is appreciated.

These type of links are root links where instead of linking relative to the file that you are on, it links relative to the root directory.

 

This comes in handy when you are dealing with files that are going to be repeated in numerious places all over the site and a general link such as about/index.php isnt going to work all the time. For example: Say I have a php include that controls the main navigation. if I have a link on there that is such about/index.php. That link isn't always going to be valid for sites that are in sub directories. The link would have to change to ../about/index.php. So clearly something has to change. If you take the reference from the root directory, you can have the same url and it would work such as /about/index.php.

 

Does that make sense? Im not really good at explaining that.

What he said, although i prefer to use the base reference tag, a little overlooked gem.

 

For me it's critical, because if i like relative to the root on my host, i have to write links like /node27/1335/www/http/sites/mydomain.com/

 

and as soon as a switch host, that's bound to change. Plus in xampp the root is 127.0.0.1 whereas my sites are located in 127.0.0.1/sites/ or 127.0.0.1/templates/ and so on.

 

Long story cut short

 

add this into your head

 

<base href="http://www.mydomain.com/" />

 

and it will add the domain to the beginning of all relative links, so it eradicates the need for ../ and /

 

Plus if you switch domains, all you need to do is update that one tag and it will adjust all your links to the new domain, easy peasy.

 

If that makes sense.

 

So if you had a global nav with relative links, as soon as you start placing it in subfolders, you'd have to start adding ../ infront to go up directories. Wheras with the base reference you don't have to work backwards, only forwards. It's similar to using / to get the the root, but the root directory varies from system to system.

 

So rather than having

 

../../mylink.html

 

you could just use

 

mylink.html

 

lets add another two subfolders, which would make the relative link

 

../../../../mylink.html

 

but with a base ref.

 

it's still

 

mylink.html

 

[/end ramble]

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.