Can someone please explain how site internal links work in Drupal? What is the most reliable way to display a link so that it goes to the same location every time?

I'm working on a preliminary website and right now, the only reliable way I can get a link to work the same way on all pages is to use absolute links (starting with http://and including the domain name for the host) for each link. Since this website is currently local, this is not practical because I'll need to change all the links in the website when it goes live.

Eventually, I'd like to put these links in a menu I've got displayed at the top of all pages in my site.

  • It's not clear what you are asking. Please post some example code and explain how it behaves currently and how you wish it would behave.
    – LunkRat
    May 24, 2014 at 2:29

3 Answers 3


In HTTP, links starting with http:// and including a domain name (e.g. http://example.com/foo/bar) is known as absolute paths. On a Drupal site, they should only be used for off-site links. Links not starting with http:// (e.g. /foo/bar) is known as relative paths. Relative paths should be used for internal links on your site. When a relative path starts with a slash (/) it is relative to the Drupal site root. When it does not, it is relative to the location where it is embedded.

By making sure all internal links are specified using relative paths, they will not have to be changed when you move your site from one server to another.

For example, to link to /node/42, (provided you've clean URLs enabled) you can use the following markup:

 <a href="/node/42">Link to node 42</a>

(For menu items, as described bellow, you should omit the initial /, as menu items are always relative to the Drupal root.)

Eventually, I'd like to put these links in a menu I've got displayed at the top of all pages in my site.

Support for this use case is already in place in Drupal.

Navigate to: Administration » Structure » Menus and click on the link "List links" for the Main menu. Then click on Add link. In the field "Path" type in the relative path to the location (e.g. node path) in your site you want this menu item to point. Also provide meaningful "Menu link title" and "Description" strings. End by clicking Save. Now the link will appear in your main menu, which in most (including the default "Bartik") themes are displayed at the top of all pages on the site.

  • Thanks! using the preceding "/" to refer to the root worked! I feel like I tried this before with strange results but for now, it seems to be working!
    – daniella
    May 27, 2014 at 14:41

Drupal 6 (obsoleted)

Path Filter rewrote internal:node/123 links to e.g. http://example.com/en/content/my-node-alias

Drupal 7

Pathologic offers the same feature (though only minimally documented)

Drupal 8

Pathologic is currently (2018-01) not yet usable.

Internally drupal has uri schemes like base:robots.txt, entity:node/1, route:myroute/arg1/arg2 that you can use in e.g. menu links. But there seem not to be a text filter that leverages these.


If you're still fairly new to Drupal and haven't seen it yet, you might want to add in ckeditor and ckeditor_link modules. This will provide your users with an easy way of adding internal links within your site without having to worry about paths and links with any markup.

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.