Make it possible to link to an entity by UUID

Created on 9 October 2014, over 9 years ago
Updated 27 October 2023, 8 months ago

Problem/Motivation

It would be great to provide URLs with UUIDs in their so you can link to them.

The solution would need to meet the following requirements:

  • Allow a UUID-based URL to be used in menus, end-user-facing links should use a path alias when available
  • Allow a UUID-based URL to be used for front page, 403 and 404 pages, without strange redirection by-effects
  • Allow a UUID-based URL to be used as in the page condition for e.g. block-placement. It should not make a difference if the alias-, numeric ID- or UUID-based URL is used, the block should be shown regardless of the URL used to access the content
  • The "duplicate content" situation is not made worse then it is, i.e. search engines should be guided to a canonical URL somehow, either by redirects (for aliases and traditional numeric URLs this is handled by Redirect module in contrib) or a canonical metatag

Proposed resolution

The most recent solution uses a path converter. It relies on the existing behaviour of setting the canonical meta tag to avoid duplicate content issues in terms of SEO (because that is already the approach taken with aliases vs. system paths). Internally, the path is converted to the numeric path, so that anything relying on that also works for the UUID-based URL.

Add a new uuid link template for entities:

$node->toUrl('uuid');

Remaining tasks

  • [ ] Resolve #2690747: [PLAN] Create an index of UUIDs โ†’
  • [ ] Adapt path processor that can up-cast an {uuid} anywhere in an URL without needing to know the actual entity type
  • [x] Add special case code to Entity::toUrl() to handle 'uuid'
  • โ“Test all use cases
  • [ ] Update CR

User interface changes

The UUID-based URL is available.

API changes

It is possible to request the UUID-based URL for an entity.

โœจ Feature request
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component
Entityย  โ†’

Last updated about 1 hour ago

  • Maintained by
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom @catch
  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland @Berdir
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany @hchonov
Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany dawehner

Live updates comments and jobs are added and updated live.
  • Contributed project blocker

    It denotes an issue that prevents porting of a contributed project to the stable version of Drupal due to missing APIs, regressions, and so on.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany C-Logemann Frankfurt/M, Germany

    This Issue started with this text by @dawehner:

    > It would be great to provide URLs with UUIDs in their so you can link to them.

    > For poormans menu staging you could use menu_link_config and store refs to UUIDs, like uuid/{entity_type}/{uuid}
    which page does a 301 redirect to the actual entity page.

    I think this issue should stay on focus with the "{entity_type}/{uuid}" plan. Getting the entity_type removed from the urls is interesting but I think this should move to another issue including all the problems and dependencies like #2690747: [PLAN] Create an index of UUIDs โ†’ .

    Because of symfony and ParamConverter etc. there are many possibilities to fix things in contrib. So I just decided to solve things there. At first I will concentrate on user entities (e.g. "uuid/user/{uuid}") because I need a solution where users should not know their serial uid. After doing some tests today I think this is basically not complicated.

    Especially for everything related to nodes, aliases, and redirects things are more complicated. And that's another reason to stay focused on {entity_type} in paths. For me he user part is the most important thing because I don't want to replace the user entity. Since we can create our own entity types with nearly everything a node can do this would be easier. And on the project where I need user/uuid paths I haven't decided yet if I really want to use nodes.

    (I will add a comment here when there is a project I will add my solutions.)

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany DiDebru
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vsujeetkumar Delhi

    Re-roll patch created for 11.x.

  • last update 8 months ago
    Custom Commands Failed
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vsujeetkumar Delhi

    Fixed the CCF issue, Please have a look.

  • last update 8 months ago
    30,444 pass, 1 fail
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vsujeetkumar Delhi

    Fixed the failed test cases.

  • last update 8 months ago
    30,448 pass
Production build 0.69.0 2024