Should I use relative or absolute urls when pointing to internal pages

It depends on what you’re talking about. If you’re talking about using just

<a href="https://wordpress.stackexchange.com/page-title">Page Title</a>, then no. It’s better to use the full link.

However, instead of using http://www.domain.com/page-title, it’s better to use

<?php echo bloginfo('url'); ?>/page-title.

The reason you don’t want to use relative links is the way wordpress permalinks work. If you’re on a sub-page (domain.com/about/john) and you use a relative link to another subpage (href="https://wordpress.stackexchange.com/jane"), it will point to the root URL (domain.com/jane instead of domain/about/jane.

UPDATE

The full <a> will be

<a href="https://wordpress.stackexchange.com/questions/24476/<?php echo bloginfo("url'); ?>/page-title">Page Title</a>

Leave a Comment