简体   繁体   中英

How link to /something in the current page

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?

You can just do this:

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

Tell me if this doesn't work

./ 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM