Reputation: 3523
I always learned to link to pages on the same site I should do the below:
/page1.php
/page2.php
/page3.php
/subdir/
/page4.php
/page5.php
<a href="./page2.php">Linking to page in same folder</a>
<a href="./subdir/page4.php">Linking to a page one folder deeper</a>
<a href="./page5.php">Linking to page in same folder</a>
<a href="../page3.php">Linking to a page one folder up</a>
However, substituting ./page2.php
with just page2.php
works as well.
<a href="page2.php">Linking to page in same folder</a>
How is it properly done/which is better? On my personal website, the statistics show a lot of incoming traffic from my own site: is this because I'm using ./
when I don't need to?
Upvotes: 0
Views: 54
Reputation: 2778
It's the same. The .
directory is explicitly "this directory", but if your href
doesn't start with a /
or a scheme (http://
for instance), then it is considered relative to the current directory anyway. It's up to you which to use. Personally I would leave out the .
, since it serves no purpose, and in my opinion doesn't make it easier to read.
Upvotes: 2