I'm working on localhost server and I added an anchor tag like below in block.

<a href="contactus">Contact</a>

In front page it goes to the path directly, but if it is other than front page, it added the current path also, for example


It add the "content" in front of the path, then it return "page not found".

how to define path in anchor tag ? or is that anything I'm missing ?


3 Answers 3


If you are using the non-aliased path, use l() to create your link. By non-aliased, I mean the Drupal system path (e.g. node/235 instead of about-us). The non-aliased path for the Contact page is contact. This is really the best approach.

<a href="<?php print l('contact'); ?>">Contact</a>

But if you have an aliased path (e.g. about-us or contact-us), then use base_path().

<a href="<?php print base_path() .'contact-us'; ?>">Contact</a>

You can use the base_path() function to get the url with trailing slash '/'

  • 1
    Yes, 'base_path()' function work with 'php filter' text format. Oct 28, 2013 at 5:08

Do you have a path alias defined for contactus (i.e. alias: contactus, system: node/3)?

I don't have a D6 system handy to look at, but in D7 you can check this at admin/config/search/path

If so, and assuming Drupal is at the domain root "/", then you just need to adjust your link from:

<a href="contactus">Contact</a>


<a href="/contactus">Contact</a>

And it should work everywhere on your site.

  • Your answer assumes that the Drupal site is located at domain root, which is not always the case.
    – kekkis
    Oct 27, 2013 at 21:45
  • True. But I would still verify what aliases exist to prevent confusion. I've edited the answer to make the assumption clear.
    – Dave Bruns
    Oct 28, 2013 at 1:44
  • @kekkis it works for my case.
    – Bala
    Oct 28, 2013 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.