We have a site that features two languages, EN (primary/default) and JA. On one content page, we link to another node using it's nid: url('node/123'). In EN, this returns the alias and not the node based url. When in the JA language, this returns a url like /ja/node/123 which then shows text in the EN variant when we expect JA. There are aliases set for both EN and JA, which both point to the same desired URL like: /products/new-fancy-product and their respective node id urls. In EN, url returns this alias correctly.

Also, if I change /products/new-fancy-product to /ja/products/new-fancy-product in the address bar, I get the correct JA version of the page as I want.

Why is url not returning me the correct alias instead of the node id path, which then just shows EN content?

1 Answer 1


Use l() function to generate a link.

Formats an internal or external URL link as an HTML anchor tag.

This function correctly handles aliased paths and adds an 'active' class attribute to links that point to the current page (for theming), so all internal links output by modules should be generated by this function if possible.

  • This just appears to wrap a call to url which isn't working. How will this help?
    – Chris
    Apr 18, 2016 at 19:20
  • @Chris have you actually tried using l() instead of url()?
    – oksana-c
    Apr 18, 2016 at 20:45
  • Yes, it returns the sam thing as url except with link fully built and ready for use in html: /ja/node/123. This still gives me the english version, and doesn't properly resolve the alias which should be /ja/products/new-fancy-product
    – Chris
    Apr 19, 2016 at 13:41

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.