2

Never thought Drupal's way to use relative URLs everywhere in template files was a problem until I happened on https://stackoverflow.com/questions/17187437/relative-urls-in-wordpress and read some arguments against using relative urls of many WP developers including core ones. Copying them here:

  • Root-relative URLs aren't really proper. /path/ might not be WordPress, it might be outside of the install. So really it's not
    much different than an absolute URL.
  • Any relative URLs also make it significantly more difficult to perform transformations when the install is moved. The find-replace
    is going to be necessary in most situations, and having an absolute
    URL is ironically more portable for those reasons.
  • absolute URLs are needed in numerous other places. Needing to add these in conditionally will add to processing, as well as introduce
    potential bugs (and incompatibilities with plugins).
  • Relative to what, I'm not sure, as WordPress is often in a subdirectory, which means we'll always need to process the content to then add in the rest of the path. This introduces overhead.
  • Keep in mind that there are two types of relative URLs, with and without the leading slash. Both have caveats that make this impossible to properly implement.
  • WordPress should (and does) store absolute URLs. This requires no pre-processing of content, no overhead, no ambiguity. If you need to relocate, it is a global find-replace in the database.

Now I wonder how much those concerns are legitimate in general, in if they or some of them are, then how much this relates to Drupal in particular?

1
  • 1
    Where exactly are you worried about entering these urls? Commented Dec 12, 2016 at 14:53

1 Answer 1

0

As a developer who has worked extensively with both Drupal and Wordpress I have to say that the convenience of Drupal's relative URLs outweighs the (apparent) accuracy of Wordpress's absolute URLs.

  • When moving a site from dev > staging > production a Wordpress site's URLs and image references have to be replaced in the DB, this can create an absolute mess.
  • Rather than creating links between pages as hyperlinks a good Drupal setup uses entity reference and entity embed, so if the path or URL of a file changes the page's source is still correct.
  • Wordpress feeds are natively better as the URLs are natively absolute, Drupal views feeds can be made to use content filters to make links absolute.
  • In Drupal I like to use a module called pathologic to set absolute URLs in the rendered source, the stored source however remains free of site domain.
  • Performance hit of content filtering is negligible on Drupal and there are multiple layers of caching.

Hope that answers some people's questions if they arrive here.

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.