See #2418017-78: Implement autocomplete UI for the link widget and onwards for the discussion that sparked this issue.
Drupal has for a long time used the special token <front> in various UIs to represent the front page of the site. In Drupal 8, we are standardizing all user-entered paths in menu links as /something/something (with a leading slash), which matches how those routes are defined in YAML for consistency. It also allows us to give us a way to signify we do not want the autocomplete behaviour of the menu link UI once #2418017: Implement autocomplete UI for the link widget makes it in.
However, <front> is inconsistent with this new direction, and so it's proposed to remove this abstraction and instead make it just /, which would match the mental model used for all other links.
And, if we choose to remove <front> support for the link widget, the question is if we must also remove it from other places where we use it, such as the path aliases UI, block visibility rules, etc.
Places where <front> is currently used
At the time of writing there are 216 references in code, tests, or comments. Here's what a simple grep looks like: https://www.drupal.org/files/issues/front-usages.txt Fancier greps welcome!
Reasons to do this
- The primary reason is consistency with the rest of the web (how URLs work).
<front>is a Drupalism./is not. (It's straight-up how URLs work (if you type<a href="/">home</a>you'll also get a link to the home page). Removing<front>means to have a consistent mental model for the user: thinking about the web, URLs and linking in Drupal, it's all a single, consistent mental model. <front>is an English string and not translatable, versus/is the same in any language. This fits in well with Drupal 8's goal of being more multilingual-friendly.- We require a leading slash for every path. Hence the
<front>one-off is highly inconsistent; it breaks the mental model. - Another reason is code simplification. With this change, we're able able to remove a lot of annoying code like this:
- if (strpos($string, '<front>') === 0) { - $string = '/' . substr($string, strlen('<front>')); - } - elseif (strpos($string, '<none>') === 0) { - $string = substr($string, strlen('<none>')); - } - elseif (!in_array($string[0], ['/', '?', '#'])) { - $string = '/' . $string; - }In favour of just:
+ // Detect a schemeless string, map to 'user-path:' URI. + elseif (!empty($string) && parse_url($string, PHP_URL_SCHEME) === NULL) { + $uri = 'user-path:' . $string; }
Removing all occurrences would be nice, but not necessary because the places where you can enter "old style path input" is strictly limited to site administrators/site builders, whereas the "new style path input" (i.e. the changes made here to LinkWidget) affect content authors.
Reasons not to do this
- Requires long-time users to unlearn old habits, and invalidates long-standing documentation. It also creates an annoying inconsistency for anyone using both D6/7 and D8 sites at the same time, which will be basically everyone for the next 1-2 years, at least. (Though could combat this concern to some extent by back-porting optional support for "/" to D7.)
- We're now exposing internals of how our backed works to end-users, particularly content authors since this change will affect link fields as well.
<front>is a plain-English string that (to native English speakers) is extremely clear (except for non-native speakers)./is not obvious to a layperson without a background in web development, though is at least intuitively known at some level by anybody who has frequently seen or created links. - Comparing https://www.drupal.org/project/i18n and https://www.drupal.org/project/usage/drupal shows that approximately 15% of all Drupal sites are successfully using multilingual functionality with the current
<front>token, so this does not seem to be a significant barrier to multilingual adoption. (But that doesn't mean it's not a usability problem or a Drupal WTF.) -
On removing all occurrences:
- Taking a look at how often
<front>is actually used, it's a not insignificant chunk of work to complete this issue, when we already have several not insignificant chunks of work that we actually need to complete in order to ship Drupal 8. - It also would require extra work for the D6/D7 migrate team to change all instances of
<front>in various database tables to/(which they already have to do anyway, to migrate them touser-path:URIs).
Goal
It's unclear if the benefits outweigh the impact here, both on users and on the Drupal 8 release timeline. That's what we're here to discuss in this issue.
- Taking a look at how often
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | php 8.2 link.jpg | 147.32 KB | lazzyvn |
| #1 | front-usages.txt | 25.21 KB | webchick |
Comments
Comment #1
webchickOk, tried to capture the various pros and cons from the other discussion in the issue summary. I really tried to keep it neutral, but I'm sure it needs some work.
And despite my personal feelings on the topic, I also don't see anything about this that would match the priority of "major" over at https://www.drupal.org/node/45111 so reducing to normal. Happy to have it changed back though if justification can be provided.
Comment #2
webchickComment #3
wim leersThe IS was IMHO unfair; it presented the points as if the only reason to remove
<front>was code cleanliness. Whereas the actual reason is that it is a total mismatch with the rest of the mental model.It also posed that removing
<front>support fromLinkWidgetrequires it being removed from block visibility et cetera, which is not true.Clarified the IS accordingly, I hope webchick agrees.
Comment #4
webchickIssue summary looks good now, thanks. Not sure I see this tip the balance in a beta evaluation, though. Would love some other opinions.
Comment #5
Bojhan commentedThanks for starting this issue, I am happy that we moved this to another issue. I do wish to clarify that stating "the mental model" might be a little ambiguous here. Since the mental model around URL's vastly differ per user (from the developer, to the user that thinks you enter a URL in the google search bar). We are serving a very wide audience with this functionality and connected pages.
I am however all for dropping it is a oddity and doesn't really map to anything else we have in the system. Other than a "learned pattern" its not really a usable concept, as you have to read the help text and connect the dots to understand its meaning. Going forward, we should drop this - and I don't think we can in a point release. In general we should aim to make Drupal consistent, having one pattern exist next to another one is both UX and DX wise bad practice. Which should make it validate for the beta gate, it reduces fragility (two models), it is a follow-up on a major, it is a usability improvement and frankly I don't really think it's disruptive (its just like any concept change and easy to migrate).
Most of the reasons mentioned, are non-reasons to me. Documentation (any large change, requires docs changes), multilingual (we have loads more prominent labels that have poor translatability). The fact that it impacts release in some way - sure, but so does any other issue that is not a release blocker. This doesn't need to be on OCTO's list, can be of course - you need some relaxation from all that performance stuff :)
Comment #6
mac_weber commentedConsistency FTW.
As @Bojhan said, I also don't think this causes a big impact that would stop it from being implemented in D8.
+1 for removing it now.
Comment #7
wim leersQuoting @Bojhan in #5:
We could do this in 8.1.
Comment #9
mac_weber commentedMoving this issue to "Routing System" to call attention from other developers from related system. Moreover, this change should happen not only for the link field, but for the whole system.
Comment #11
andrej galuf commentedI would like to point your attention to #1543750: Allow menu items without path, where another path similar to <front> is to be used - the <none> - to allow non-link menu items. Whereas <front> has a direct replacement in '/', <none> has no such replacement and would then remain an oddity.
I believe that the above issue should be solved first before deciding the fate of <front> and <none>.
Comment #12
andypostAlso there's related issue about
<no-link>&<none>"empty" links #2698057: Add support for <nolink> and <none> to the LinkWidget UIComment #24
lazzyvn commentedcompatible with php 8.2
there is big probleme with php 8.2

parse_url($uri, PHP_URL_SCHEME) will return NOTHING or 'internal:'
php 8.1 will return 'internal'
as you see in core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php Line 149
it will return all errors with the internal link. because parse_url($uri, PHP_URL_SCHEME) is not supported in php 8.2
I suggest changing condition if
Comment #26
chri5tia commentedCommenting here because the link to this ticket was next to the verbiage I am commenting on.
When entering an external URL, it's required to provide protocol (https, http, etc.), which does not start with any of the options below (`/`, `?`, and `#`. These only seem to apply to internal paths. Aside from the expected `<` as well, for ``, skipping over that conversation, the error message doesn't indicate the reason for the form being rejected, which is that it is missing the `https`. Recommend changing the text to explain why an external link starting with www, for example, causes the error.
"Manually entered paths should start with one of the following characters: / ? #" could say something like "Manually entered internal paths must start with `/`, `?`, or `#`. External paths must begin with a protocol such as `https:`, `http`, `ftp`, etc."