I have a website with a ‘home’ link like many do and I am wondering whether I should do:
<a href="./">Home</a>
or
<a href="index.html">Home</a>
Obviously my homepage is contained in the index.html file. I have the first option implemented right now and it seems to work, but I am not sure what the preferred practice is or if there are any drawbacks to one or the other.
I appreciate any help!
Using
href="/"may require the browser to submit two requests. The first to"/"which is redirected at the server to"index.html". If it’s not a 302 redirect, then there may be some potential search indexing implications, though that’s subjective voodoo that may not apply.The other issue is if your server just returns the contents of
index.htmlfor"/". When that is true your site will have two different URLs for the same resource. Not having canonical URLs for the same reference will affect your search performance.While linking to
"/"may offer some flexibility in that you can change it in the future, the difference betweenindex.htmlandindex.phpis usually a significant architectural change and “future proofing” against is pointless. If you’re switching to a dynamic site in the future, you’ll be updating all your home links anyway…so no need to optimize for what won’t ever happen.