Mobile app version of vmapp.org
Login or Join
Murphy175

: Best practice how to specifiy the link's destination In my website, I have many files such contact.php, about.html etc. Right now I can call those file in my site by two methods. Method

@Murphy175

Posted in: #Hyperlink #Links #Performance #RelativeUrls #Seo

In my website, I have many files such contact.php, about.html etc. Right now I can call those file in my site by two methods.



Method 1:

<a href="http://www.example.com/contact.php">Contact</a>


Method 2:

<a href="contact.php">Contact</a>


Which is most preferable in point of SEO as well as performance?

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Murphy175

3 Comments

Sorted by latest first Latest Oldest Best

 

@Vandalay111

There are pros and cons for using both of the options. In point of SEO however it doesn't matter.

Using relative links (Method 2 in your question) is good if you need to change the domain in later point, as it will keep your html files fully functional (if you keep the same structure of course). The con of using this method is mainly the chance for mistakes. One wrong trailing slash, one missed dot when you want to go back in the structure, and you have 404.

The absolute links (Method 1) are somehow easier for maintenance and debugging, and they make it easier to change a structure of your website, if you need (simple Find by the domain name and you have all links easy spotted, so you can change them in seconds). Also you don't need to worry about the directives like ./ or ../ (switching between folder levels) - you just put the absolute link and you are ready to go.

Overall - it's about preference, but it's best if you choose one and use it site-wide. Mixing both methods increase the risk you'll generate some 404 sooner or later.

10% popularity Vote Up Vote Down


 

@Harper822

For many web pages, either method will work just fine without a bad impact on performance or SEO, however if your site has a single page with hundreds of links or more, then I'd go with method two and specify a default path via the BASE tag in order to not screw up links since that will cut down on code size and therefore reduce loading time.

So as an example, Instead of having the following in your HTML source code:

<a href="http://example.com/a/very/long/path/to/file.php?a=1">One</a>
<a href="http://example.com/a/very/long/path/to/file.php?a=2">Two</a>
<a href="http://example.com/a/very/long/path/to/file.php?a=3">Three</a>
<a href="http://example.com/a/very/long/path/to/file.php?a=4">Four</a>
<a href="http://example.com/a/very/long/path/to/file.php?a=5">Five</a>


You can have:

<base href="http://example.com/a/very/long/path/to/">


Along with:

<a href="file.php?a=1">One</a>
<a href="file.php?a=2">Two</a>
<a href="file.php?a=3">Three</a>
<a href="file.php?a=4">Four</a>
<a href="file.php?a=5">Five</a>


And its also a bonus if you can use friendly URLs, because then you could create a one-character hrefs such as this:

<a href="1">One</a>
<a href="2">Two</a>
<a href="3">Three</a>
<a href="4">Four</a>
<a href="5">Five</a>


And you can for example place this code that's accessible in a URL such as example.com/sections. That way, when a link is selected, the number is added to the URL resulting in for example: example.com/sections/1

10% popularity Vote Up Vote Down


 

@Nimeshi995

Neither matter for SEO at all when you consider relative or full path URLs.

What matters is the link text and the target page as well as where the link exists in content. As your example, assuming that this is a navigational link, there will be little value for the link text, however, it will have some value assuming that exists within a <nav> tag. Otherwise for links within content, the surrounding content block, the link text, and the content of the target page matters. Content quality of both the page where the link resides and the target page is important.

Again, relative or full path URLs make no difference for SEO. Please do not overthink the process. SEO is rather simple. It is about the content and making your site as user friendly and compelling as possible.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme