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

  1. 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.
  2. <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.
  3. We require a leading slash for every path. Hence the <front> one-off is highly inconsistent; it breaks the mental model.
  4. 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

  1. 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.)
  2. 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.
  3. 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.)
  4. On removing all occurrences:

    1. 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.
    2. 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 to user-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.

CommentFileSizeAuthor
#24 php 8.2 link.jpg147.32 KBlazzyvn
#1 front-usages.txt25.21 KBwebchick

Comments

webchick’s picture

Priority: Major » Normal
Issue summary: View changes
StatusFileSize
new25.21 KB

Ok, 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.

webchick’s picture

Issue summary: View changes
wim leers’s picture

Issue summary: View changes

The 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 from LinkWidget requires it being removed from block visibility et cetera, which is not true.

Clarified the IS accordingly, I hope webchick agrees.

webchick’s picture

Issue summary looks good now, thanks. Not sure I see this tip the balance in a beta evaluation, though. Would love some other opinions.

Bojhan’s picture

Thanks 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 :)

mac_weber’s picture

Consistency 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.

wim leers’s picture

Version: 8.0.x-dev » 8.1.x-dev

Quoting @Bojhan in #5:

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.

We could do this in 8.1.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mac_weber’s picture

Component: link.module » routing system

Moving 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.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andrej galuf’s picture

I 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>.

andypost’s picture

Also there's related issue about <no-link> & <none> "empty" links #2698057: Add support for <nolink> and <none> to the LinkWidget UI

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

lazzyvn’s picture

StatusFileSize
new147.32 KB

compatible with php 8.2

$uri ='internal:#123';
$p = parse_url($uri, PHP_URL_SCHEME);
print_r($p);

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'
php 8.2
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

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

chri5tia’s picture

Commenting 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."

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.