WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

Last modified 4 years ago

#6599 closed feature request (invalid)

Inpage URLs can be realtive instead of being always absolute.

Reported by: hakre Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.7
Component: General Keywords:
Focuses: Cc:

Description

Wordpress has a long tradition of absolute URLs or URIs. Any link or href it stumbles over is tried to be converted in something absolute.

Internet Hypertext Documents (HTML) is aware about two type of URIs/URLs: absolute and relative. A relative URL is converted to an absolute one by the client then.

Wordpress can benefit if it starts to use relative URLs instead of absolute ones under many circumstances:

  • Output filesize will be reduced
  • Blogs can be moved more easy from one domain to another because the content is then more domain independent.
  • ...

Places absolute URLs are used which can be easily replaced with relative ones are:

  • All the links inside a post
  • HTML HEAD for stylesheet and scripts
  • In the Admin, many javscript files are referenced with an absolute URI.

Change History (18)

comment:1 follow-up: Otto426 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

This is incorrect. Replacing these absolute URLs with relative ones will break all non-default permalink systems.

Recognize that relative URLs work in one of two ways:

  • from root
  • from the current URL

Using root level relative URLs would break WordPress's ability to be easily installed in a subdirectory of a site.

Using current URL relative links breaks permalinks, because the point of permalinks is that they bear no relationship to the underlying file system structure of the site. What is a single relative link to, say, a CSS file that works when the current URL is both http://example.com/blog/ and http://example.com/blog/2008/04/15/single-post/ ?

No, we use absolute URLs for a very good reason, and those absolute URLs are built on the fly from the settings. The site remains portable when coded correctly (using bloginfo('url') calls and similar to display the root URL instead of hardcoding it.

Closing this as invalid.

comment:2 Otto426 years ago

  • Milestone 2.7 deleted

comment:3 Otto426 years ago

  • Resolution wontfix deleted
  • Status changed from closed to reopened

comment:4 Otto426 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed

comment:5 in reply to: ↑ 1 ; follow-up: hakre5 years ago

  • Cc hanskrentel@… added
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Type changed from enhancement to feature request

I've missed the comments here for quite some time. But that is no problem, since the topic itself did not change since all the versions:

Replying to Otto42:

This is incorrect. Replacing these absolute URLs with relative ones will break all non-default permalink systems.

Permalinks Argument:
"A permalink, or permanent link, is a URL that points to a specific blog or forum entry after it has passed from the front page to the archives" (Definition by Wikipedia)

Because a Permalink is an URL/URI, writing it as a relative or absolute one does not make any difference. Your argumentation just fails here.

Replying to Otto42:

Recognize that relative URLs work in one of two ways:

  • from root
  • from the current URL

Another misunderstanding. Relative URLs are always built upon the current URL -or- the BASE element. The term "from root" is misleading here and only named so that you can start another invalid and misleading argumentation:

Replying to Otto42:

Using root level relative URLs would break WordPress's ability to be easily installed in a subdirectory of a site.

That it was. I will just ignore this further to better pinpoint the rest.

Using current URL relative links breaks permalinks, because the point of permalinks is that they bear no relationship to the underlying file system structure of the site. What is a single relative link to, say, a CSS file that works when the current URL is both http://example.com/blog/ and http://example.com/blog/2008/04/15/single-post/ ?

No, we use absolute URLs for a very good reason, and those absolute URLs are built on the fly from the settings.

Well if there would be "a very good reason", then please name it. Or proof the Opposite of: "Using absolute URLs (and/or the BASE Element) in Webapps is for coding noobs. This is done by those who did not understand how links work or who do not want to solve linking properly and stable."

The site remains portable when coded correctly (using bloginfo('url') calls and similar to display the root URL instead of hardcoding it.

Have you ever taken a look how WordPress does link to files? That is all but _not_ done properly. In opposite to what you write, the URLs hard hardcoded into the content and not generated by "using bloginfo('url')" when the page is displayed.

Closing this as invalid.

Re-Opening this as feature request. It's not invalid and many pplz. over and over dicuss about this in the community.

comment:6 in reply to: ↑ 5 ; follow-ups: Otto425 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed

Replying to hakre:

Because a Permalink is an URL/URI, writing it as a relative or absolute one does not make any difference. Your argumentation just fails here.

I'm sorry, but you are mistaken.

If I have a permalink that looks like this:

http://example.com/blog/2009/name-of-post

And it contains a relative image link, like "image.jpg", then that is going to resolve to http://example.com/blog/2009/name-of-post/image.jpg by the browser.

The problem is that image.jpg does not exist there, as the entire permalink structure (everything after "blog") is pretend. It's make-believe. The directories don't actually exist. That's what the rewriting is all about.

Another misunderstanding. Relative URLs are always built upon the current URL -or- the BASE element. The term "from root" is misleading here and only named so that you can start another invalid and misleading argumentation:

Umm.. No. Sorry, but you're wrong again. Here's two examples:

IMG SRC="/blog/uploads/2009/image.jpg"
IMG SRC="image.jpg"

Both of those are relative. The first one is root-relative (as it include the leading /) , and using that format would actually work. A browser would not resolve it from the current path, but from the current domain (the leading slash makes it do that).

Well if there would be "a very good reason", then please name it. Or proof the Opposite of: "Using absolute URLs (and/or the BASE Element) in Webapps is for coding noobs. This is done by those who did not understand how links work or who do not want to solve linking properly and stable."

In order to disprove that nonsensical claim, it would first have to be demonstrated at all in some way. The idea that one-way or another-way is for "noobs" is simply ridiculous on the face of it.

Relative URLs make sense in some situations, and absolute URLs make sense in others. There is never a one-size-fits-all solution, and only "noobs" would think otherwise. ;-)

Have you ever taken a look how WordPress does link to files? That is all but _not_ done properly. In opposite to what you write, the URLs hard hardcoded into the content and not generated by "using bloginfo('url')" when the page is displayed.

I am aware of that. It's a problem, admittedly, but if you've examined the importer, there's a method it uses to correct those links when you use an Export/Import and migrate attachments in that manner.

Re-Opening this as feature request. It's not invalid and many pplz. over and over dicuss about this in the community.

Closing it as invalid again, because it is. Don't reopen it without some form of, you know, logic. Or at least knowing what you're talking about.

Also, Trac is not the place for debate on whether something is a good idea or not. Take it to wp-hackers if you want to debate it.

comment:7 in reply to: ↑ 6 hakre5 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Replying to Otto42:

Replying to hakre:

Because a Permalink is an URL/URI, writing it as a relative or absolute one does not make any difference. Your argumentation just fails here.

I'm sorry, but you are mistaken.

If I have a permalink that looks like this:

http://example.com/blog/2009/name-of-post

And it contains a relative image link, like "image.jpg", then that is going to resolve to http://example.com/blog/2009/name-of-post/image.jpg by the browser.

The problem is that image.jpg does not exist there, as the entire permalink structure (everything after "blog") is pretend. It's make-believe. The directories don't actually exist. That's what the rewriting is all about.

It seems to me, we are not talking about the same terms. Maybe we can get those clear before continuing to argue.

Definition of Terms (Suggestion)

  • Link (HTML): As describben in rfc1866;
    absolute URI
                a URI in absolute form; for example, as per [URL]
    base URI
                an absolute URI used in combination with a relative URI
                to determine another absolute URI.
    URI
                A Uniform Resource Identifier is a formatted string that
                serves as an identifier for a resource, typically on the
                Internet. URIs are used in HTML to identify the anchors
                of hyperlinks. URIs in common practice include Uniform
                Resource Locators (URLs)[URL] and Relative URLs
                [RELURL].
    [RELURL]
                Fielding, R., "Relative Uniform Resource Locators", RFC
                1808, June 1995
                <URL:ftp://ds.internic.net/rfc/rfc1808.txt>
    [URI]
                Berners-Lee, T., "Universal Resource Identifiers in WWW:
                A Unifying Syntax for the Expression of Names and
                Addresses of Objects on the Network as used in the
                World- Wide Web",  RFC 1630, CERN, June 1994.
                <URL:ftp://ds.internic.net/rfc/rfc1630.txt>
    [URL]
                Berners-Lee, T., Masinter, L., and M. McCahill, "Uniform
                Resource Locators (URL)", RFC 1738, CERN, Xerox PARC,
                University of Minnesota, December 1994.
                <URL:ftp://ds.internic.net/rfc/rfc1738.txt>
    
  • Permalink: As describben here (wikipedia).

Any Problems with that?

comment:8 Otto425 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed

I know what the terms mean, thank you very much. And defining your terms doesn't make you any more correct than before. You're still wrong, for the same reasons I've already given.

comment:9 in reply to: ↑ 6 ; follow-ups: hakre5 years ago

  • Milestone set to Future Release
  • Version set to 2.7

Glad to see you agree to the specs, so we can get into a factual agrumentation again.

Replying to Otto42:

Replying to hakre:

Because a Permalink is an URL/URI, writing it as a relative or absolute one does not make any difference. Your argumentation just fails here.

I'm sorry, but you are mistaken.

Please name the point where I am actually mistaken.

If I have a permalink that looks like this:

http://example.com/blog/2009/name-of-post

And it contains a relative image link, like "image.jpg", then that is going to resolve to http://example.com/blog/2009/name-of-post/image.jpg by the browser.

You mean, if there is a link on the page "http://example.com/blog/2009/name-of-post" with the relative URL "image.jpg".

The problem is that image.jpg does not exist there, as the entire permalink structure (everything after "blog") is pretend.

I have never spoken about putting senseless links into a page. Absolute links which are senseless would point to the same 404 files. For example taking the absolute URL "http://example.com/blog/2009/name-of-post/image.jpg" to link to that nonexisting image would lead to a 404 as well. It is a question of creating URL that leads to a 200. That URL can be realtive or absoulte.

It's make-believe. The directories don't actually exist. That's what the rewriting is all about.

Can you imagine that it is possible to provide a valid realtive link?

Another misunderstanding. Relative URLs are always built upon the current URL -or- the BASE element. The term "from root" is misleading here and only named so that you can start another invalid and misleading argumentation:

Umm.. No. Sorry, but you're wrong again.

You said you stick with the terms. I do not need to speak for myself with that one, just take a look into the docs: http://www.w3.org/Addressing/rfc1808.txt with Focus on Sections "3. Establishing a Base URL" and "4. Resolving Relative URLs".

Here's two examples:
IMG SRC="/blog/uploads/2009/image.jpg"
IMG SRC="image.jpg"

Both of those are relative.

TRUE

The first one is root-relative (as it include the leading /) , and using that format would actually work. A browser would not resolve it from the current path, but from the current domain (the leading slash makes it do that).

As in the first point: You can't compare an 404 leading links with a 200 leading link. If the Post has the following Permalink: "http://example.com/supersite/special/blog/2009/name-of-post"

Here's two examples:
IMG SRC="/blog/uploads/2009/image.jpg"
IMG SRC="image.jpg"

will lead to 404 both.


Well if there would be "a very good reason", then please name it. Or proof the Opposite of: "Using absolute URLs (and/or the BASE Element) in Webapps is for coding noobs. This is done by those who did not understand how links work or who do not want to solve linking properly and stable."

In order to disprove that nonsensical claim, it would first have to be demonstrated at all in some way. The idea that one-way or another-way is for "noobs" is simply ridiculous on the face of it.

Relative URLs make sense in some situations, and absolute URLs make sense in others. There is never a one-size-fits-all solution, and only "noobs" would think otherwise. ;-)

Well, I do not like to have that much focus on the Noob argument but more in the arguments for using realtive links:

  • There is actually no argument for or against realative vs. absolute.
  • All links are absolute at least for a user using a website.
  • The website itself can therefore provide relative links.
  • There is no need to have absolute links (only) in the output from server-side.
  • There is _absolutely_ no need to have absolute links hardcoded in database data. Infact, this leads to problems (as documented).
  • Because there is no need that there must be absolute links in the output, it is more wise to handle relative URIs in (database) data to convert them to links useable to (the current and often changing) Blog configuration.


Have you ever taken a look how WordPress does link to files? That is all but _not_ done properly. In opposite to what you write, the URLs hard hardcoded into the content and not generated by "using bloginfo('url')" when the page is displayed.

I am aware of that. It's a problem, admittedly, but if you've examined the importer, there's a method it uses to correct those links when you use an Export/Import and migrate attachments in that manner.

Well, that is why it is sooo much easier to get over these problems and provide absolute links. So if wordpress would use realtive links, that would be a sign that it has been taken care of something.


Re-Opening this as feature request. It's not invalid and many pplz. over and over dicuss about this in the community.

Closing it as invalid again, because it is. Don't reopen it without some form of, you know, logic. Or at least knowing what you're talking about.

Having relative pointer to image/file data within blog-post-data can help to more easily migrate and reconfigure a blog.

Also, Trac is not the place for debate on whether something is a good idea or not. Take it to wp-hackers if you want to debate it.

This is a feature request not a debate.

comment:10 in reply to: ↑ 9 Otto425 years ago

Replying to hakre:

I have never spoken about putting senseless links into a page. Absolute links which are senseless would point to the same 404 files. For example taking the absolute URL "http://example.com/blog/2009/name-of-post/image.jpg" to link to that nonexisting image would lead to a 404 as well. It is a question of creating URL that leads to a 200. That URL can be realtive or absoulte.

But that URL is "fixed". It cannot be changed once you've created it, because it is actually saved into the post content itself. And it is used on multiple different pages, such as http://example.com/blog/, http://example.com/blog/category/some-cat, http://example.com/blog/2009/, http://example.com/blog/2009/name-of-post, etc, etc.

The post content does not change, the location where that content is displayed does.

Can you imagine that it is possible to provide a valid realtive link?

No, I cannot, please tell me what a valid relative link would be for an image displayed in all the locations where it can be displayed.

As in the first point: You can't compare an 404 leading links with a 200 leading link. If the Post has the following Permalink: "http://example.com/supersite/special/blog/2009/name-of-post"

Here's two examples:
IMG SRC="/blog/uploads/2009/image.jpg"
IMG SRC="image.jpg"

will lead to 404 both.

No, in fact, it would not lead to a 404 on both, as the root-relative link can be made to work, while the non-root relative link can't.

There is a fundamental difference there that you need to understand. I'm not making things up here, I really do know what I'm talking about. So please, just for a moment, pretend that I'm saying something you're not understanding instead of thinking that I'm arguing with you just because I have nothing better to do.

comment:11 in reply to: ↑ 9 Otto425 years ago

Replying to hakre:

Well, I do not like to have that much focus on the Noob argument but more in the arguments for using realtive links:

  • There is actually no argument for or against realative vs. absolute.

False, there are situations where absolute links make more sense. Like the one I'm describing now, for example.

  • All links are absolute at least for a user using a website.

That doesn't make any sense. A link is either relative or absolute. It makes no difference who the user is.

  • The website itself can therefore provide relative links.
  • There is no need to have absolute links (only) in the output from server-side.
  • There is _absolutely_ no need to have absolute links hardcoded in database data. Infact, this leads to problems (as documented).

So, you want to make all links in posts dynamic in some way, so that instead of having the link in the post itself (as in HTML), you have something else and then replace it with the relative link as the post is displayed?

Because I have to vote a big -1000000 to that idea. The idea that the post can be altered on display is one thing, but to needlessly abstract it just for the sake of providing relative links instead of absolute ones, when absolute ones work perfectly fine, strikes me as a bit too much. It's like swatting a fly with an AK-47.

  • Because there is no need that there must be absolute links in the output, it is more wise to handle relative URIs in (database) data to convert them to links useable to (the current and often changing) Blog configuration.

Why are relative links preferred? I can think of no sensible reason to care whether they're absolute or relative, as long as the user sees the bloody page in the end. The only problem with them is that it makes moving the blog URLs slightly more difficult, but that's extremely minor by comparison to abstracting out the entire post content structure in order to make all links dynamically generated.

comment:12 follow-up: hakre5 years ago

Otto42, you're judging about all this if there would already be a concrete implementation you must talk against. It's just a feature request. I have gotten many Feedback about that from diverse forums so I opened it up here. Just take that as it is. There is no must be relative links but to be free-thinking about the Issue. You write it yourself:

"I can think of no sensible reason to care whether they're absolute or relative, as long as the user sees the bloody page in the end" (by Otto42)

So therefore I would strongly speak about having relative links where they make sense, for example in the database data where those links can be realtive to the upload path for files. Just to give you an Idea. Since those links are relative, they can greped with ease and change to (absolute) links in the webblog output. (only to give an idea, this should not be a concrete implementation).

comment:13 in reply to: ↑ 12 Otto425 years ago

Replying to hakre:

Otto42, you're judging about all this if there would already be a concrete implementation you must talk against. It's just a feature request.

I understand that, but even a feature must be judged as being worth it or harmful or what have you.

So therefore I would strongly speak about having relative links where they make sense, for example in the database data where those links can be realtive to the upload path for files. Just to give you an Idea. Since those links are relative, they can greped with ease and change to (absolute) links in the webblog output. (only to give an idea, this should not be a concrete implementation).

Such an feature basically adds a lot of seemingly useless work to the system. You're running a lot of extra CPU cycles here, for no real tangible benefits that I can see. So I think the "feature" doesn't make any sense.

comment:14 hakre5 years ago

There is very much code WordPress running useless CPU-Cycles with every request only to handle absolut URLs. Believe me. You can judge that punctually on it. It really is a Feature Request and I assume this Feature is that bold, that it - if implemented - will affect a lot. If I would only replace some output then this can stay with absolut urls as well and a little output bufferung bracket and some replacements afterwards.

comment:15 Otto425 years ago

There is absolutely zero code needed to handle absolute URLs, because those URLs are in the post_content itself. It's not like it is adding those on the fly or some such thing.

comment:16 in reply to: ↑ 6 Denis-de-Bernardy5 years ago

  • Milestone Future Release deleted

Replying to Otto42:

If I have a permalink that looks like this:

http://example.com/blog/2009/name-of-post

And it contains a relative image link, like "image.jpg", then that is going to resolve to http://example.com/blog/2009/name-of-post/image.jpg by the browser.

actually, it will resolve to:

http://example.com/blog/2009/image.jpg

I'm 100% with Otto on this, for reasons he outlined and because quite a few (broken...) feed readers don't process relative urls properly.

:-)

comment:17 hakre5 years ago

the topic says "can" not "must".

comment:18 hakre4 years ago

Internal linking is around the corner.

Note: See TracTickets for help on using tickets.