? Pending

User tests: Successful: Unsuccessful:

avatar csthomas
csthomas
10 Oct 2018

Pull Request for Issue #9010

Summary of Changes

Remove tag from html document.
Check the conversation on #22565

Testing Instructions

Check html code on front-end. After patch the <base> tag is missing.

Expected result

There is no <base> tag. Anchor links works if you are on page with a query like ...?start=2.

Actual result

The <base> tag exists, but if you are on page with a query like ...?start=2 then anchor does not work correctly and reload the page.

Documentation Changes Required

The <base> tag has been removed from HTML version of the document.

avatar csthomas csthomas - open - 10 Oct 2018
avatar csthomas csthomas - change - 10 Oct 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 10 Oct 2018
Category Libraries
avatar csthomas csthomas - change - 10 Oct 2018
Title
Remove html <base> tag
Remove html tag
Labels Added: ?
avatar csthomas csthomas - change - 12 Oct 2018
The description was changed
avatar csthomas csthomas - edited - 12 Oct 2018
avatar brianteeman
brianteeman - comment - 17 Oct 2018

surely without the base relative urls wont work correctly?

avatar csthomas
csthomas - comment - 17 Oct 2018

surely without the base relative URLs wont work correctly?

it will work even better

Relative URLs (relative to the <base> tag) are links that:

  • does not start with /
  • may start with . or .. or index.php or ?page=... or #hash or text/...

Relative URLs (relative to the domain) are links that:

  • start with a slash /, mainly used in joomla

Now, take a look at the example when joomla set the base tag URL as http://www.example.com/category/1-article on page http://www.example.com/category/1-article.

  1. Every URL which start with / (slash) does not use the base tag.
  2. You can not use anchor "#hash" when there is URL query (http://www.example.com/category/1-article?start=10) - it will reload page
  3. You can not use the base tag URL to generate a link to images, css or javascript file. The base URL (http://www.example.com/category/1-article/) point to the virtual folder.

It would be better to set the base URL as the same as current page, ex http://www.example.com/category/1-article?start=10 but then browser does not need the base tag.
Then, the anchor href="#hash" will work even with query parameters in the page URL.

The alternative solution is #22565.
Then, the anchor won't work but we can use the base URL to generate links to css, images and javascript like media/system/jquery... instead of

  • /media/system/jquery...
  • /prefixToJoomlaInstallation/media/system/jquery... - if you install joomla in subfolder
  • /~user/prefixToJoomlaInstallation/media/system/jquery... - if you install joomla on a Linux user account
avatar csthomas
csthomas - comment - 17 Oct 2018

To remove the base tag, you can add to your template index.php (somewhere at the top) the php code
JFactory::getDocument()->setBase(''); and then test if your website still works.

avatar csthomas
csthomas - comment - 17 Oct 2018

And for the sites installed as subdirectories, what kind of havoc does this bring?

AFAIK missing the base tag is equal to the base URL as Uri::getInstance(), but now Joomla use Uri::current().

The difference is that now (before patch) the base tag URL does not contain URL query.

Currently, the base tag URL AFAIK is not useful anywhere in joomla core. There is no havoc.

Personally I use solution from #22565 (JFactory::getDocument()->setBase(JUri::root());) to fix a problem when an extension use only index.php in html code.
<form action="index.php"><input name="option" value="com_...">...</form>.

When I use #22565 it always point to http://domain.com/index.php (in my develop version to http://localhost/~csthomas/joomla3/index.php).
Without it, the action URL will point to http://domain.com/category/index.php if I am on http://domain.com/category/1-article.

These two versions works but I do not like to see weird links like http://company.com/news/people/index.php.

#22565 will bring one issue, the anchor like <a href="#hash">...</a> will always reload the page.
Currently, Joomla only reload the page when there is a query in page URL.

avatar mbabker
mbabker - comment - 17 Oct 2018

Honestly, at this point I'm leaning toward "change it in 4.0 and leave 3.x alone". It's a change in API behavior that's been there for 10 years and if we're going to change it then we really need to make sure that it doesn't come with major side effects.

avatar csthomas
csthomas - comment - 17 Oct 2018

OK, I can create a new PR on 4.0-dev but which PR will be more suitable?

  1. The base tag URL as Uri::getInstance() - current PR
  2. The base tag URL as Uri::base() - #22565
avatar mbabker
mbabker - comment - 17 Oct 2018

I'm the wrong person to ask, I haven't written code that touches or relies on a <base> tag probably ever.

avatar csthomas
csthomas - comment - 17 Oct 2018

Hmm, I suppose no one wants to answer.

While I checked WordPress, Drupal, TYPO3 and ... they do not use the base tag at all.

I will leave this PR open for a while.

avatar mbabker
mbabker - comment - 17 Oct 2018

It's not that I don't want to help here, I just don't have the knowledge to say anything useful on the topic and any answer I have would probably be something you've already stumbled on in your own search.

avatar csthomas
csthomas - comment - 17 Oct 2018

I am grateful that you joined the discussion, everything is fine.

avatar bembelimen
bembelimen - comment - 17 Oct 2018

The base-tag is broken since nearly forever I think.

The Joomla links only work thanks to the SEO plugin, which do some Voodoo with all the links/images/applets etc. so they ignore the base tag.

So I personal think, that, if the base tag should be changed in any way, then it should be repaired not removed. Means:

  • change base tag to the current base path ("/" if site is in root or "/subfolder/" when in a subfolder)
  • remove the hacks in the SEO plugin
  • generate the correct links/file paths relative to the base path.

This would solve some problems with JS and update of html content (inject images via JS)

avatar csthomas
csthomas - comment - 18 Oct 2018

@bembelimen I understand you are voting for point 2 (# 22565)

avatar brianteeman
brianteeman - comment - 18 Oct 2018

I just tested this on one of my live sites. After applying the patch I can confirm that the base tag is no longer present

However - after applying the patch
All menu links are now non-sef
All direct links (eg manually created) display the home page even if the url in the address bar has changed
All bookmarked links display the home page even if the url in the address bar has changed

avatar brianteeman
brianteeman - comment - 18 Oct 2018

I have tested this item ? unsuccessfully on 21306af


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22571.

avatar brianteeman brianteeman - test_item - 18 Oct 2018 - Tested unsuccessfully
avatar brianteeman
brianteeman - comment - 18 Oct 2018

I didn't test anchor links as there was no point with such a big failure


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22571.

avatar csthomas
csthomas - comment - 18 Oct 2018

@brianteeman I do not know how you test it, but I can not believe in all your arguments.
You probably do something more that only add a patch from this PR. This PR remove only one html tag.

I can understand that it may affect to manually created links without the slash prefix like news/my-article.

Never mind, I'm closing to save us time.

avatar csthomas csthomas - close - 18 Oct 2018
avatar csthomas csthomas - change - 18 Oct 2018
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-10-18 09:44:38
Closed_By csthomas
avatar brianteeman
brianteeman - comment - 18 Oct 2018

I can assure you that the only thing I changed on the live site was the code here in this pr

avatar ggppdk
ggppdk - comment - 20 Oct 2018

Is removing base tag in J4 still considered ?
or it will not happen there either ?

avatar csthomas
csthomas - comment - 20 Oct 2018

I would like to see it in J4.

Add a Comment

Login with GitHub to post a comment