0

UPDATE:

I am using EJS, and i have a partial file with a simple navbar to change the language, i want require this partial in all my pages, code:

<aside class="language">
  <a href="/pt">
    <i class="flag-icon flag-icon-br"></i>
  </a>
  <a href="/es">
    <i class="flag-icon flag-icon-es"></i>
  </a>
  <a href="/en">
    <i class="flag-icon flag-icon-us"></i>
  </a>
</aside>

The problem here, is:

The links are pointing to /, and i want change to the current path, for example:

If i am in the /something page, i want the links pointing to /something/pt, /something/en and something/es

How achieve this?

  • not actually get what you want ? assume that user in another folder and need to return to something/language, try "../something/language" – Deeper Feb 11 '15 at 00:56
  • possible duplicate of [Basic HTML - how to set relative path to current folder?](http://stackoverflow.com/questions/296873/basic-html-how-to-set-relative-path-to-current-folder) – showdev Feb 11 '15 at 01:06
  • this is not what i want @showdev, i want create a path to the current PAGE, not folder man... –  Feb 11 '15 at 01:09
  • In your samples, you seem to be referring to a directory, not a page: `/something/pt`. Are you performing some sort of rewrite? – showdev Feb 11 '15 at 01:20
  • nop, im referring to pages, this partial is been used in several pages, i need change the links to the current path, if the user is in the /page1, i need change the links to /page1/pt, /page1/en and /page1/es, get it? –  Feb 11 '15 at 01:24
  • can u take off the possible duplicate? this is not a duplicate.. u miss understood the question.. –  Feb 11 '15 at 01:48
  • Sorry, I don't see the difference between what you describe and my answer or the duplicate. I've tested the code in my answer and it functions exactly as you describe. Is it possible to link to a working example that demonstrates your issue and helps me better understand your question? – showdev Feb 11 '15 at 18:45

2 Answers2

0

You can just do this:

<a href="/something/language"><a>

Tell me if this doesn't work

Sachin
  • 737
  • 1
  • 9
  • 23
0

./ refers to the current directory. So, in your case:

<a href="./pt">
    <i class="flag-icon flag-icon-br"></i>
</a>
<a href="./es">
    <i class="flag-icon flag-icon-es"></i>
</a>
<a href="./en">
    <i class="flag-icon flag-icon-us"></i>
</a>

These link as follows:

example.com        =>   example.com/pt
example.com/sub    =>   example.com/sub/pt
showdev
  • 28,454
  • 37
  • 55
  • 73
  • this is not working, i still have the same problem.. if i am in the /something page, the link still pointing to the root.. –  Feb 11 '15 at 01:10