I understand that Drupal uses <front> to designate the frontpage but how do I use this in an <a href> tag or do I have to hardcode the site's full root url in there instead?

TIA

Comments

ecstasy2’s picture

To link to your front page, there many way.
but my favorite is :

<a href="<?php print ('<front>');?>" >My Front page</a>

hope this help you.

marcvangend’s picture

It depends a little on where you need it. "<front>" is something you would use in admin forms, like the menu system or a block configuration page. When I need this somewhere in php code, I use drupal's l() function:
print l('front','');
or, if you want an absolute link including the http:// and the domain name:
print l('front','',array('absolute'=>true));
See http://api.drupal.org/api/function/l for more info on the l() function.

datarazor’s picture

If you want to link to your front, DON'T use php in the node as then your content admins have to either use PHP, or get granted permission to use that input-format... instead just do this:

<a href="/" ...></a>

The forward slash is correctly interpreted to be your front page by Drupal.

Voila!

vbalsys’s picture

It won't work if drupal site is hosted in a directory (like example.com/mydrupalsite).

Anonymous’s picture

Thanks to both of you.

This advice is really helpful and worth keeping somewhere on a quick reference sheet.

Does such exist?

marcvangend’s picture

There are several cheat sheets, aimed at different audiences (themers, coders, end-users). Just search Google for "drupal cheat sheet".