more of an aspiration than a claim

WordPress Relative URL - Why use Absolute URLs?

So you want to know why WordPress uses an absolute URL when creating a link within your own WordPress site? When WordPress stores an absolute URL in the database, it makes it harder to create test or development versions of your site. I normally solve this by making the site name point to the server I want (perhaps another article on this). Another alternative is to run some database scripts to change your site name in the database stored URLs.

Some reasons for WordPress absolute URL usage in favor of relative URLs can be found in an answer for this StackOverflow question quoting a WordPress lead core developer.

  • Performance may be better as there is processing involved to construct a WordPress relative URL.

  • the root URL (ie /) can change depending on your setup of WordPress. Changing relative URLs is more error prone.

  • Internally WordPress requires absolute URLs in certain areas and processing this is considered a potential area to introduce programming bugs.

  • Some plugins do not handle relative URLs correctly. SEO Guru Yoast is also quite vocal about relative URLs and issues they have caused himself and also for his clients including:

  • Duplicate Content of your test server

    • an accidental link to a test environment version of your site can lead to duplicate content issues by accidentally indexing your test site.
  • Spider Traps

    *   a relative link ./oops instead of ../oops, can cause a recursive link like /page/oops/oops/oops/ etc. Best not to annoy Google ;)

    Also see our upcoming article about trailing slashes on URLs. https://example.com/test is a different URL to https://example.com/test**/**