In header.php I can do the following:

<base href="<?php echo get_bloginfo('template_url');?>/"/>

That way I can keep my layout images path relative.

   <img src="imgs/img.png"/>

Instead of

   <img src="<?php echo get_bloginfo('template_url');?>"/>

Is there any downside of settings the base url? Any possible conflicts with wordpress?

  • 2
    Your question as written is fairly opinion based and not actually specific to WordPress. Also, get_bloginfo('template_url') is deprecated in favor of get_template_directory_uri().
    – mrwweb
    Aug 26, 2014 at 20:59
  • I disagree. If I were to post here, 'should I use get_posts()', I would get 4000 answers telling me not to use it because it's a bad idea because of so and so... that's what I am looking for with this question. It's related to wordpress because I am looking for possible conflicts with wordpress.
    – gdaniel
    Aug 26, 2014 at 21:16

2 Answers 2


So in general there are two opinions on absolute versus relative URLs:

  • use relative URLs because easier to move around
  • use absolute URLs because easier to move around

Confusing, yes. The argument boils down to that migrating things with relative URLs you don't need to change domain. The counter argument is that you might need to change levels or URLs and then relative suddenly turns into complete nightmare.

Regardless of which camp is "right" — WordPress is firmly in the absolute URL camp. All it's API functions will output absolute URLs and it's intended workflow for anything related in it.


Personally I wouldn't use it - I see no real advantage over using absolute href and src attributes in your theme, and you'll avoid breaking relative links within post content.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.